Created
August 12, 2015 16:33
-
-
Save kiichi/1e583422fd932a0e47a1 to your computer and use it in GitHub Desktop.
Complete File Upload Example from Microsoft
This file contains hidden or 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
| <%@ 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