Guest User

Untitled

a guest
Jan 23rd, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. $('#modalWindow').on('click', '#send', function () {
  2. $.ajax({
  3. type: "POST",
  4. url: "/Home/LoadImage",
  5. data: {
  6. "base64img": $('#autoPicture').attr('src')
  7. },
  8. success: function (data) {
  9. alert('Привет');
  10. },
  11. error: function (error) {
  12. alert(error.responseText);
  13. }
  14. });
  15. });
  16.  
  17. $('#modalWindow').on('change', '#fileLoader', function () {
  18. ReadImageUrl(this);
  19. });
  20.  
  21. function ReadImageUrl(input) {
  22. if (input.files && input.files[0]) {
  23. var reader = new FileReader();
  24.  
  25. reader.readAsDataURL(input.files[0]);
  26.  
  27. reader.onload = function (e) {
  28. $('#autoPicture').attr('src', e.target.result);
  29. }
  30. }
  31. }
  32.  
  33. [HttpPost]
  34. public ActionResult LoadImage(string base64img)
  35. {
  36. byte[] picture = Convert.FromBase64String(base64img);
  37.  
  38. return View();
  39. }
Add Comment
Please, Sign In to add comment