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 like when you want to attach file when you’re sending an email.
我想使用C#在Visual Studio中向我的Web应用程序添加文件上传按钮,以允许用户在PC上浏览图片以将其保存在数据库中。就像您在发送电子邮件时要附加文件一样。
How can I add a file upload button to my website?
如何在我的网站上添加文件上传按钮?
5 个解决方案
#1
2
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>
#2
2
In web application do you mean asp.net
?
在网络应用程序中你的意思是asp.net?
If so, you can use File Upload
control.
如果是这样,您可以使用文件上载控件。
<asp:FileUpload ID="FileUpload1" runat="server" />
#3
1
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:
并在服务器端将此byte []写入数据库字段:
FileUpload1.FileBytes
#4
0
use this
<input type="file" name="datafile" size="40">
indside a form.
一个表格。
#5
0
You can find the basic information on HTML input tag over here. Working example
您可以在此处找到有关HTML输入标记的基本信息。工作实例
#1
2
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>
#2
2
In web application do you mean asp.net
?
在网络应用程序中你的意思是asp.net?
If so, you can use File Upload
control.
如果是这样,您可以使用文件上载控件。
<asp:FileUpload ID="FileUpload1" runat="server" />
#3
1
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:
并在服务器端将此byte []写入数据库字段:
FileUpload1.FileBytes
#4
0
use this
<input type="file" name="datafile" size="40">
indside a form.
一个表格。
#5
0
You can find the basic information on HTML input tag over here. Working example
您可以在此处找到有关HTML输入标记的基本信息。工作实例