-
url: (your test url)/Upload/?fileName=hello2.jpg
-
method: POST
-
Body -> form-data
-
Key could be blank but select file type. In value, select a file.
Last active
June 17, 2017 04:28
-
-
Save kiichi/3588880d7217cde2529648ea71e6e65d to your computer and use it in GitHub Desktop.
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
| [Route("Upload/")] | |
| [HttpPost] | |
| public async Task<object> Upload(string fileName){ | |
| string path = Path.GetTempPath(); | |
| var provider = new MultipartFormDataStreamProvider(path); | |
| await Request.Content.ReadAsMultipartAsync(provider); | |
| var tmpFilePath = provider.FileData.Select(entry => entry.LocalFileName).First(); | |
| var targetFilePath = Path.Combine(@"C:\tmp\", fileName); | |
| File.Copy(tmpFilePath,targetFilePath); | |
| return fileName + " has been saved on " + targetFilePath + " via " + tmpFilePath; | |
| } |
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
| <system.web> | |
| <httpRuntime maxRequestLength="30000000" /> | |
| </system.web> | |
| <system.webServer> | |
| <security> | |
| <requestFiltering> | |
| <requestLimits maxAllowedContentLength="30000000" /> | |
| </requestFiltering> | |
| </security> | |
| </system.webServer> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment