Thursday, 15 May 2014

c# - Using HTML5 file (Multiple) control in asp.net -



c# - Using HTML5 file (Multiple) control in asp.net -

i looking way manage <input type="file" multiple="multiple"> tag of html 5 in asp.net 3.5 project. have done before single command on page, if have multiple upload controls on same page. please see code:

protected void btnsave_click(object sender, eventargs e) { //---------need check if upload command has files: please suggest perfect way if (fupattachment.postedfile != null || fupattachment.postedfile.filename != "" || fupattachment.postedfile.contentlength>0)//here problem, not checks blank file upload command httpfilecollection hfc = request.files; string strdirectory = server.mappath("~/") + "mailer/" + hidcampid.value; if (hfc.count>0) { if (!system.io.directory.exists(strdirectory)) { system.io.directory.createdirectory(strdirectory); } if (system.io.directory.exists(strdirectory)) { (int = 0; < hfc.count - 1; i++) { hfc[i].saveas(strdirectory + "/" + hfc[i].filename.replace(" ", "_")); } } } } }

my asp page this:

//----this command want multiple upload files <input type="file" multiple="multiple" runat="server" id="fupattachment" /> // upload command there takes input when page loads <asp:fileupload id="fupmailinglist" runat="server" />

so, problem when page loads "fupmailinglist" has taken file, , when want utilize multiple upload command "fupattachment", unable check if has files or not, hfc checks upload controls , gets file in 1 of them. so, please tell me way check "fupattachment" command , work correctly.

rather iterating on files in request, should check on per input basis.

var uploadedfiles = request.files.getmultiple("fupattachment"); if(uploadedfiles.count > 0) { // }

c# asp.net html5 file-upload

No comments:

Post a Comment