Skip to content

Instantly share code, notes, and snippets.

@scottsappen
Created July 1, 2013 14:42
Show Gist options
  • Save scottsappen/5901423 to your computer and use it in GitHub Desktop.
Save scottsappen/5901423 to your computer and use it in GitHub Desktop.
ASP.Net friendly uploaded POST file receiver
//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