Learn how to a build a cloud-first strategyRegister Now


upload file in ASP.NET (VB)

Posted on 2011-10-10
Medium Priority
Last Modified: 2012-05-12
Hi guys,

Does anyone know how to upload a file selected with FileUpload?

Also, can I also list .TXT and .CSV when the BROWSE button is clicked on the FileUpload control? Thanks!

Question by:pvg1975
LVL 10

Accepted Solution

himanshut earned 1200 total points
ID: 36946063
LVL 12

Assisted Solution

by:Ramkisan Jagtap
Ramkisan Jagtap earned 800 total points
ID: 36946743

Protected Sub UploadButton_Click(sender As Object, e As EventArgs) _
    Handles UploadButton.Click
    If UploadTest.HasFile = False Then
        ' No file uploaded!
        UploadDetails.Text = "Please first select a file to upload..."
        ' Display the uploaded file's details
        UploadDetails.Text = "Uploading Text File "        ' Save the file
        Dim filePath As String = _
            Server.MapPath("~/Brochures/" & UploadTest.FileName) ' here youset a file path to upload
        UploadTest.SaveAs(filePath)  ' here you are actully uploads file to the mapped path

    End If
End Sub

You can not apply filter to open dialog but you can add custom validation to fileuploder so that no files will be uploaded other than .TXT and .CSV
Please refer following link :

Author Comment

ID: 36950284
Thanks guys

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Integration Management Part 2
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question