Advertisement
Guest User

Untitled

a guest
Sep 20th, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. <form id="uploadform" name="uploadform" method="POST" enctype="multipart/form-data">
  2. <input id="realupload" name="realupload" type="file" multiple/>
  3. <input id="uploadsubmit" type="submit" value="upload"/>
  4. </form>
  5.  
  6. $('#uploadsubmit').click(function(e)
  7. {
  8. e.preventDefault();
  9.  
  10. $.ajax({
  11. type: "POST",
  12. url: "upload.php",
  13. data: function(){
  14. alert("test");
  15. var data = new FormData();
  16. data.append("realupload", jQuery("#realupload").get(0).files[0]);
  17. return data;
  18. }
  19. ,
  20. processData:false,
  21. contentType: false,
  22. cache: false,
  23. success: function(theData){
  24. $('#innercontent').html(theData);
  25. },
  26. error: function() {
  27. $('#innercontent').html("ERROR, HELP");
  28. }
  29. });
  30.  
  31. }
  32. });
  33.  
  34. <?php
  35. //upload.php
  36. if (isset($_FILES["realupload"]))
  37. {
  38. echo "SUCCESSFUL UPLOAD " . $_FILES["realupload"]["error"];
  39. }
  40. else{
  41. echo "FILES NOT SET";
  42. }
  43. ?>
  44.  
  45. Hello,
  46.  
  47. Just use new jquery library jquery-2.1.1.min.js
  48.  
  49. from
  50.  
  51. http://jquery.com/download/
  52.  
  53. It will definitely solve your problem
  54.  
  55. Few days before i was stuck with same problem so I gave try for above library it did worked for me.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement