Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. btnsubmit.click(function(){
  2. var file_data = $('#uploaded_img').prop('files')[0];
  3. var form_data = new FormData();
  4. form_data.append('file', file_data);
  5.  
  6. $.ajax({
  7. url: 'upload_img_custom.php',
  8. cache: false,
  9. contentType: false,
  10. processData: false,
  11. data: form_data,
  12. type: 'POST',
  13. success: function(php_script_response){
  14. alert(php_script_response);
  15. }
  16. });
  17. });
  18.  
  19. <?php
  20. $upload_directory = "../uploads/Customized/";
  21. if (isset($_FILES['uploaded_img']))
  22. {
  23. $uploadedFileName=$_FILES['uploaded_img']['name'];
  24. $targetPath=time().$uploadedFileName; //time is concatenated to make filenames unique
  25. if($uploadedFileName != '')
  26. {
  27. $targetPath=time().$uploadedFileName;
  28. move_uploaded_file($uploadedFileName, $upload_directory."".$targetPath);
  29. }
  30. }
  31. header('Location: customize.php?upload=success');
  32. ?>
  33.  
  34. <form method=POST id=customize-form action ="" enctype=multipart/form-data>
  35. <div id=step3 class='options step'>
  36. <section class=section-title>Image</section>
  37. <div class=image-display><img id=image-disp src="" width=99 style="text-align:center" /></div> //div for displaying uploaded image
  38. <section style="margin-bottom:10px">
  39. <label class="paragraph-font2 full-width">Choose what you want on the top of your cake:</label>
  40. </section>
  41. <section style="margin-bottom:15px">
  42. <input class="paragraph-font2 full-width" type=file name=uploaded_img id=uploaded_img accept="image/*">
  43. </section>
  44. </div>
  45. <button type=submit class='btn btn-info action submit'><span class='glyphicon glyphicon-shopping-cart'></span> Add to cart</button>
  46. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement