I have a form that submit value to the server though ajax.
<form> <input id="titlee" name="titlee"> <input type="file" name="fileToUpload" id="fileToUpload"> <button type="submit" value="submit" id="submit" name="submit">Start</button> <div class="progress"></div> </form> Script
<script type="text/javascript"> $(function() { $("#submit").click(function() { var titlee = $("#titlee").val(); var fileToUpload= $("#fileToUpload").val(); var dataString = 'titlee='+ titlee + '&fileToUpload=' + fileToUpload; $.ajax( { type: "POST", url: "c_insert_test.php", data: dataString, success: function() }); return false; }); }); </script> c_insert_test.php
<?php $titlee = $_POST['titlee']; $target_dir = "reqdoc/"; $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION); $new_filename = $target_dir . uniqid() . '.' . $imageFileType; if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $new_filename)) { $filee = $new_filename; // insert query to insert the image path and other parameters in the table } else { echo "false"; } ?> For the progress bar I have code here at this jsfiddle
I wish to display a progress bar while the paramters and the image gets uploaded to the server through the form. However I am not able to merge the progress bar with the ajax, can anyone please tell how i can merge these 2 code so that i can display the progress bar and upload the image to the server folder