browse local disk drive

browse local disk drive

Post by U3RhbmxleS » Thu, 21 Oct 2004 08:25:02


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
 
 
 

browse local disk drive

Post by Sm9yZ2UgTW » Sat, 23 Oct 2004 05:25:05

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">

 
 
 

browse local disk drive

Post by wessamzeid » Sat, 23 Oct 2004 20:01:20

use a file field html control
 
 
 

browse local disk drive

Post by Sm9yZ2UgTW » Sat, 23 Oct 2004 20:31:07

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)));
}
}
}