Advertisement
julong

upload ajax with ajax #laravel

Aug 5th, 2014
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>test upload image</title>
  6. <?php echo HTML::script('assets/js/modernizr.custom.75994.js'); ?>
  7. <?php echo HTML::script('/bower_components/jquery/dist/jquery.min.js'); ?>
  8. <?php echo HTML::style('/bower_components/bootstrap/dist/css/bootstrap.min.css'); ?>
  9. </head>
  10. <body>
  11. <form action="">
  12. <input type="file" name="image" id="">
  13. <br/>
  14. <button type="submit">upload</button>
  15. </form>
  16. <script>
  17.  
  18. var form = document.querySelector('form');
  19. var request = new XMLHttpRequest();
  20.  
  21. form.addEventListener('submit',function(e){
  22. e.preventDefault();
  23.  
  24. var formdata = new FormData(form);
  25. request.open('post','testupload');
  26. request.send(formdata);
  27.  
  28. });
  29.  
  30. </script>
  31. </body>
  32. <?php echo HTML::script('/bower_components/jquery/dist/jquery.min.js'); ?>
  33. <?php echo HTML::script('/bower_components/bootstrap/dist/js/bootstrap.min.js'); ?>
  34.  
  35. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement