browse local disk drive

S

Stanley J Mroczek

I am looking to browse local disk drive to upload pictures to my web system.
How do i display my local files? I am using an aspx in vb
 
J

Jorge Matos

You can't programmatically browse local client files. You can use the HTML
input element to allow the user to browse for files.

<input type="file">
 
J

Jorge Matos

You could use the HTML File field control but you don't necessarily have to -
you DO need to make sure the <FORM> elements enctype attribute is set to
"multipart/form-data" see html below:

HTML:
<form id="Form1" method="post" runat="server" enctype="multipart/form-data">
<INPUT type="file">
<INPUT type="submit" value="Post file">
</form>

CODE-BEHIND:
private void Page_Load(object sender, System.EventArgs e)
{
if (this.IsPostBack)
{
if (this.Request.Files.Count > 0)
{
HttpPostedFile postedFile = this.Request.Files[0];
postedFile.SaveAs(Server.MapPath("."),
System.IO.Path.GetFileName(postedFile.FileName)));
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top