how to upload image using ajax in php -
<div class="control-group"> <label class="control-label" for="inputemail">image</label> <div class="controls"> <input type="file" value="browse" name="image" id="image" /> <span style="color: #61625f; font-weight: bolder;" class="sixth"></span> </div> </div>
ajax code below
$("#reg").click(function() { $.ajax({ url: "process_service_person_register.php", type: "post", data: "image": $("#image").val()}, });
how send image "process file"
you have use formdata object.
<script> if ("formdata" in window) { var fd = new formdata(); fd.append('file', $('#image')[0].files[0]); $.ajax({ url: "process_service_person_register.php", data: fd, processdata: false, contenttype: false, type: 'post', success: function(result) { console.log(result); } }); } else { console.log('sorry, formdata object not available.'); } </script>
without formdata, have go old school using hidden iframe method
Comments
Post a Comment