1

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.

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

2
  • 1
    <input type="file" name="theFile" /> if it's pure html; or <asp:FileUpload ... if it's Asp.Net web forms(msdn.microsoft.com/en-us/library/…) beyond that can't help much more - you will need to provide more information. Oh yeah don't forget enctype="multipart/form-data" on the enclosing form as @Widor's answer says Commented Jun 22, 2011 at 12:29
  • 10x 7assoun it is working good Commented Jun 22, 2011 at 12:33

5 Answers 5

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>
Sign up to request clarification or add additional context in comments.

Comments

2

In web application do you mean asp.net ?

If so, you can use File Upload control.

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

Comments

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:

FileUpload1.FileBytes

Comments

0

use this

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

indside a form.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.