Upload file , send response when upload is terminated
Hi , i must upload large file between 1 to 10 (size from 20 to 50 Mb ) , the script work but i must wait too many time to take the response.
How can i change page and allow user to see other page , but work the php script in background ?
this is my code:
in datiForm i append file
- $(document).ready(function() {
- $("#upload").click(function(e) {
- $.ajax({
- url: 'lavorazione_inserita.php',
- type: 'POST', //Le info testuali saranno passate in POST
- data: datiForm, //I dati, forniti sotto forma di oggetto FormData
- xhr: function() {
- var myXhr = $.ajaxSettings.xhr();
- if(myXhr.upload){
- myXhr.upload.addEventListener('progress',progress, false);
- }
- return myXhr;
- },
- cache: false,
- processData: false, //Serve per NON far convertire l’oggetto
- //FormData in una stringa, preservando il file
- contentType: false, //Serve per NON far inserire automaticamente
- //un content type errato
-
- success: function(msg)
- {
- $("#risultato").html(msg);
- $('#bar').hide();
- },
- error: function()
- {
- alert("Chiamata fallita fformdata, si prega di riprovare...");
- },
-
-
- });
-
- }
-
-
- });
-
-
-
- });
- function progress(e){
- if(e.lengthComputable){
- var max = e.total;
- var current = e.loaded;
- var Percentage = (current * 100)/max;
- //console.log(Percentage);
- $("#progress").html(Math.floor(Percentage)+'%');
- if(Percentage >= 100)
- {
- // process completed
- }
- }
- }
- </script>
The php scipt send file to dropbox and insert values in db .