Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. <form id="file_upload_form" method="post" enctype="multipart/form-data" action="">
  2. <input type="file" name="uploadcv" id="uploadcv" size="30" />
  3. </form>
  4.  
  5. var url = ServiceLocation + "/UploadFile"; //ServiceLocation = my service location
  6.  
  7. $("#file_upload_form").attr("action", url);
  8.  
  9. $("#file_upload_form").submit();
  10.  
  11. In the WCF part I used the following service method
  12.  
  13. public string UploadFile(Stream inputStream)
  14. {
  15. const int bufferSize = 8 * 1024 * 2;
  16. byte[] buffer = new byte[bufferSize];
  17. int bytesRead = inputStream.Read(buffer, 0, bufferSize);
  18. Stream outputStream = null;
  19. string newFileName = @"D:AllTxtFiles.doc";
  20. outputStream = new FileInfo(newFileName).OpenWrite();
  21.  
  22. while (bytesRead > 0)
  23. {
  24. outputStream.Write(buffer, 0, bufferSize);
  25. bytesRead = inputStream.Read(buffer, 0, bufferSize);
  26. }
  27. inputStream.Close();
  28. outputStream.Close();
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement