Skip to content

Instantly share code, notes, and snippets.

@kiichi
Created August 12, 2015 16:33
Show Gist options
  • Select an option

  • Save kiichi/1e583422fd932a0e47a1 to your computer and use it in GitHub Desktop.

Select an option

Save kiichi/1e583422fd932a0e47a1 to your computer and use it in GitHub Desktop.
Complete File Upload Example from Microsoft
<%@ Import Namespace="System"%>
<%@ Import Namespace="System.IO"%>
<%@ Import Namespace="System.Net"%>
<%@ Import NameSpace="System.Web"%>
<Script language="C#" runat=server>
/*
//Test code
byte[] responseArray = myWebClient.UploadFile(uriString,fileName);
Console.WriteLine("{0}",System.Text.Encoding.ASCII.GetString(responseArray));
// ... or simple curl
// curl -F filedata=@grumpy-cat-no-1.jpg http://helloworld.com/testupload
*/
void Page_Load(object sender, EventArgs e) {
foreach(string f in Request.Files.AllKeys) {
HttpPostedFile file = Request.Files[f];
file.SaveAs("d:\\test\\UploadedFiles\\" + file.FileName);
}
}
</Script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment