c# - Cannot get image file at server side from File Uploader in asp.net -
i have html control fileuploader
and add runat="server"
access @ server side, don't want user asp:fileuploader
because of bad css
style in bootstrap
<span> <input type="file" runat="server" id="file_upload" /> </span>
now need image html fileuploder
save in database
got example code google image fileuploader
as
byte[] imgbyte = null; if (file_upload.postedfile != null) { httppostedfile file = file_upload.postedfile; imgbyte = new byte[file.contentlength]; file.inputstream.read(imgbyte, 0, file.contentlength); }
but when examine using breakpoint
compiler not enter if
body because of null
vaule
i used this
scriptmanager.getcurrent(this).registerpostbackcontrol(this.file_upload);
in form_load
event due using asp:updatepanel
but didn't file (image) fileuploader
i need solve issue..
thanks in advance.
edit:
when remove asp:updatepanel
can access file select.
and use
<triggers> <asp:postbacktrigger controlid="file_upload" /> </triggers>
solution:
mistakenly used fileuploader's id , following @suprabhat's suggestion change
<triggers> <asp:postbacktrigger controlid="btncreate" /> </triggers>
and working fine..
try adding enctype="multipart/form-data"
attribute form
element.
Comments
Post a Comment