upload file in ASP.NET (VB)

Posted on 2011-10-10
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

    LVL 12

    Assisted Solution

    by:Ramkisan Jagtap

    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

    Thanks guys

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
    In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    733 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

    Need Help in Real-Time?

    Connect with top rated Experts

    26 Experts available now in Live!

    Get 1:1 Help Now