Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. public void Login(Stream stream)
  2. {
  3. string username = null;
  4. string password = null;
  5.  
  6. HttpContentParser parser = new HttpContentParser(stream);
  7. if (parser.Success)
  8. {
  9. username = HttpUtility.UrlDecode(parser.Parameters["username"]);
  10. password = HttpUtility.UrlDecode(parser.Parameters["password"]);
  11. }
  12. }
  13.  
  14. public void Upload(Stream stream)
  15. {
  16. HttpMultipartParser parser = new HttpMultipartParser(stream, "image");
  17.  
  18. if (parser.Success)
  19. {
  20. string user = HttpUtility.UrlDecode(parser.Parameters["user"]);
  21. string title = HttpUtility.UrlDecode(parser.Parameters["title"]);
  22.  
  23. // Save the file somewhere
  24. File.WriteAllBytes(FILE_PATH + title + FILE_EXT, parser.FileContents);
  25. }
  26. }
  27.  
  28. Microsoft.AspNetCore.Http.IFormCollection form;
  29. form = ControllerContext.HttpContext.Request.Form;
  30.  
  31. using (var fileStream = System.IO.File.Create(strFile))
  32. {
  33. form.Files[0].OpenReadStream().Seek(0, System.IO.SeekOrigin.Begin);
  34. form.Files[0].OpenReadStream().CopyTo(fileStream);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement