Permalink
Browse files

新增上传密码

  • Loading branch information...
1 parent ec86b69 commit fcb9b908cfe8543510b2d1a542e6320f11af4387 @shootsoft committed Mar 29, 2012

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -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;
@@ -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))
@@ -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())
{
@@ -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>
@@ -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'];
//服务器上临时文件名
@@ -44,7 +49,7 @@
$file_url = $s->upload( $domain , $new_file_name , $tmp_name);
alert($file_url);
} else {
- alert('null');
+ alert('密码错误或者无上传文件');
}
function alert($msg) {

0 comments on commit fcb9b90

Please sign in to comment.