开发者

How can I add a file upload button to my C# web application?

I want to add a file upload button to my web application in Visual Studio using C# in order to allow for the user to browse for a picture on his PC to save it in database. It is l开发者_JS百科ike when you want to attach file when you’re sending an email.

How can I add a file upload button to my website?


Something like

<form method="post" enctype="multipart/form-data" action="http://example.com">
<p>
Please specify a file:<br>
<input type="file" name="myfile">
</p>
<div><input type="submit" value="Send"></div>
</form>


In web application do you mean asp.net ?

If so, you can use File Upload control.

<asp:FileUpload ID="FileUpload1" runat="server" />


On client side add this to your form:

<asp:FileUpload ID="FileUpload1" runat="server" />

and on server side write this byte[] to a database field:

FileUpload1.FileBytes


use this

<input type="file" name="datafile" size="40">

indside a form.


You can find the basic information on HTML input tag over here. Working example

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜