Guest User

Untitled

a guest
Dec 12th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. <input type="hidden" name="fid" id="fid" value="5556" required>
  2. <input id="sortpicture" type="file" multiple name="sortpic[]" />
  3. <button id="upload">Загрузить файл</button>
  4.  
  5. $('#upload').on('click', function() {
  6.  
  7. var file_data = $('#sortpicture').prop('files')[0];
  8. var form_data = new FormData();
  9. form_data.append('file', file_data);
  10. form_data.append('fid', $("#fid").val());
  11. //alert(form_data);
  12. $.ajax({
  13. url: 'upload.php',
  14. dataType: 'text',
  15. cache: false,
  16. contentType: false,
  17. processData: false,
  18. data: form_data,
  19. type: 'post',
  20. success: function(php_script_response){
  21. alert("OK");
  22. }
  23. });
  24. });
  25.  
  26. var form_data = new FormData();
  27. var files = $('#sortpicture').prop('files');
  28. for (var i = 0; i < files.length; i++) {
  29. form_data.append('file_' + i, files[i]);
  30. }
  31. form_data.append('count', files.length);
  32. form_data.append('fid', $("#fid").val());
Add Comment
Please, Sign In to add comment