Skip to content

Commit

Permalink
新增上传密码
Browse files Browse the repository at this point in the history
  • Loading branch information
shootsoft committed Mar 29, 2012
1 parent ec86b69 commit fcb9b90
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 21 deletions.
51 changes: 37 additions & 14 deletions SAE Mutiple Uploads/FormMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion SAE Mutiple Uploads/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public partial class FormMain : Form
private string nameSpace;
private Uri uploadUrl;
private string localPath;
private string password;
private bool isRunning = false;
private Logger logger;

Expand Down Expand Up @@ -94,6 +95,15 @@ private void RunUpload()
Debug.WriteLine(ex);
return;
}

password = TextBoxPassword.Text;
if (string.IsNullOrEmpty(password) &&
MessageBox.Show("无密码上传?","确认") == System.Windows.Forms.DialogResult.No)
{
return;
}


nameSpace = TextBoxNamespace.Text;
localPath = TextBoxLocalPath.Text;
if (Directory.Exists(localPath))
Expand Down Expand Up @@ -132,7 +142,8 @@ private void Upload(Uri uploadUrl, string nameSpace, string path, string file)
try
{
Uri dest = new Uri(uploadUrl, "?namespace=" + HttpUtility.UrlEncode(nameSpace)
+ "&dest=" + HttpUtility.UrlEncode(file.Substring(path.Length+1).Replace("\\","/")));
+ "&dest=" + HttpUtility.UrlEncode(file.Substring(path.Length+1).Replace("\\","/"))
+"&password=" + HttpUtility.UrlEncode(password));

using (WebClient wc = new WebClient())
{
Expand Down
2 changes: 1 addition & 1 deletion SAE Mutiple Uploads/SAE Mutiple Uploads.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<None Include="SAE_PHP\sae_upload_random.php">
<None Include="SAE_PHP\sae_mutiple_uploads.php">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@
* 此文件用于SAE Storage的批量上传
* by http://www.shootsoft.net
*/


//--配置项--
//最大文件大小 10MB
$max_size = 10*1024*1024;
//密码
$cfg_password="mypassword";
//--配置项结束--

//文件保存目录路径
$domain = $_GET["namespace"];
$dest = $_GET["dest"];
//最大文件大小 10MB
$max_size = 10*1024*1024;
$password = $_GET["password"];
//有上传文件时
if (empty($_FILES) === false) {
if ( $cfg_password==$password && empty($_FILES) === false) {
//原文件名
$file_name = $_FILES['file']['name'];
//服务器上临时文件名
Expand All @@ -44,7 +49,7 @@
$file_url = $s->upload( $domain , $new_file_name , $tmp_name);
alert($file_url);
} else {
alert('null');
alert('密码错误或者无上传文件');
}

function alert($msg) {
Expand Down

0 comments on commit fcb9b90

Please sign in to comment.