Monday, September 6, 2010

VB.NET Upload & Download a file

//drag fileupload control for path and a button for upload

Dim file As String
file = Path.GetFileName(FileUpload1.FileName)
FileUpload1.SaveAs("C:\Inetpub\wwwroot\order\images\" + file)
//it is better to save file in another folde rather than the inetpub JUST LIKE BELOW
FileUpload1.SaveAs("d:\kapil\images\" + file)
lblupload.Text = "File Upload Complete...."


Response.AppendHeader("Content-Disposition", "attachment; filename=ecc1.jpg")

//By Default, maximum allowed size for file is 4MB. To allow files larger than the default of 4MB, one need to change the web.config file(in system.web TAB).There is a parameter called maxRequestLength which takes value in the KB.

//1048576 is around 1GB

No comments: