多文件上载仅在第二次单击时有效 [英] Multiple file upload works only on second click

查看:67
本文介绍了多文件上载仅在第二次单击时有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jquery.MultiFile.js在更新面板中使用fileupload控件上传多个文件,并使用触发器在按钮点击时回发但是在第一次单击时它只上传一个文件并开始上传多个文件,之后是我的代码



I am using jquery.MultiFile.js to upload multiple files using fileupload control in an update panel and using trigger to postback on button click but on first click it uploads only one file and starts uploading multiple files after that below is my code

HttpFileCollection fileCollection = Request.Files;
           for (int i = 0; i < fileCollection.Count; i++)
           {
               HttpPostedFile uploadfile = fileCollection[i];
               string file = Path.GetFileName(uploadfile.FileName);
               string extension = Path.GetExtension(file);
               if (uploadfile.ContentLength > 0)
               {
                   string no = Guid.NewGuid().ToString().Substring(0, 4);
                   string path = @"../Gallery/";
                   string serverpath = Server.MapPath(path);
                   string fullpath = serverpath + no + file;
                   uploadfile.SaveAs(fullpath);
                   valid += file + " saved successfully\\n";
               }





谢谢



Thanks

推荐答案

为文件上传控件提供UpdatePanel,并为导入按钮创建一个PostBackTrigger。
Provide the UpdatePanel for file Upload control and make a PostBackTrigger for Import button.


这篇关于多文件上载仅在第二次单击时有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆