Image Upload Ajax Jquery February 26, 2024 Post a Comment Im new to jQuery. I try to upload a jpg image file by using ajax method. But when I upload, it doesn't upload. Could anyone please help me to do this? HTML Solution 1: To upload file using ajax you must need to use FormData like below.$("form").on('submit', (function(e) { e.preventDefault; var formData = newFormData(this); $.ajax({ url : "upload.php", type : "POST", data : formData, cache : false, contentType : false, processType : false, success : function(data) { alert(data); } }); })); CopyAnd your PHP script should be like below. Baca JugaCheck That A Task Is CompletedRun An Ajax Request On A Url Blocked For Detecting Adblocker (ghostery)Fb.api Only Loads On First Ajax Call To Page<?php$image=$_FILES['image']; $image_tmp =$_FILES['image']['tmp_name']; $imagename=date("d-m-Y")."-".time().".jpg"; $target_path = "uploads/".$imagename; if(move_uploaded_file($image_tmp, $target_path)) { echo'moved'; } else { echo'error'; } ?>Copy Share You may like these postsHow To Load An Another Html File On A Button Click In Jquery MobileJquery Validation Plugin: How To Check If An Element Is Valid?Math.round Not WorkingHow To Display An Email Address For Users But Hide From Robot? Is There A Simply Way To Do It Using Php, Javascript Or Jquery? Post a Comment for "Image Upload Ajax Jquery"
Post a Comment for "Image Upload Ajax Jquery"