Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

upload file in ASP.NET (VB)

Posted on 2011-10-10
3
Medium Priority
?
280 Views
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!

Thanks
0
Comment
Question by:pvg1975
3 Comments
 
LVL 10

Accepted Solution

by:
himanshut earned 1200 total points
ID: 36946063
0
 
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..."
    Else
        ' 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 :
http://forums.asp.net/p/1156963/1902238.aspx
0
 

Author Comment

by:pvg1975
ID: 36950284
Thanks guys
0

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