Created
July 1, 2013 14:42
-
-
Save scottsappen/5901423 to your computer and use it in GitHub Desktop.
ASP.Net friendly uploaded POST file receiver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//ASP.Net libraries have many useful collection for you, one being files in the request object | |
Dim fileCollection As HttpFileCollection = Request.Files | |
//Code works, but is simplified here for you, meaning you'll want more robust error handling and logging | |
For Each uploadedFileName In fileCollection | |
Dim uploadedFile As HttpPostedFile = fileCollection(uploadedFileName) | |
If Not uploadedFile Is Nothing Then | |
If (uploadedFile.ContentLength > 0) Then | |
//Save it somewhere on the server, whatever path conventions you have | |
//also, this doesn't save it with a file extension, but you could that just the same | |
uploadedFile.SaveAs(Server.MapPath("~/Pictures/mrkangaroo")) | |
End If | |
End If | |
Next |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment