javascript - Redirect in Plupload -


wonder if can advise please - using plupload , need redirect different page add information database.

i can upload file perfectly, cannot seem redirect.

ive tried putting in code "uploadcomplete" , in different test "fileuploaded"

using firebug put in breaks script , both sections stopped @ at start, when file finished doesnt touch either of them.

therefore thought id put upload.php file in chunks section (as per google result suggested).

// check if file has been uploaded if (!$chunks || $chunk == $chunks - 1) { // strip temp .part suffix off  rename("{$filepath}.part", $filepath); $mypi = $projid; header("location: addimg.php?file=" . $filename . "&blid=" . $mypi); die(); } 

in debugging went through , hit redirect , die following, then went start of "if (!chunks etc)" , run through again, never redirected.

what missing please! im pulling out hair make work.

thanks in advance

javascript:

var uploader = new plupload.uploader({ browse_button: 'browse', // can id of dom element or dom element container: document.getelementbyid('upcontainer'), // ... or dom element  //url: 'upload.php',  url: 'uploader_plup/upload.php?wts=<?php echo $projid;?>',  chunk_size: '2mb',  max_retries: '5',        // sort files sortable: true,  // specify files browse     filters : {         mime_types:[         {title : "image files", extensions : "jpg,gif,png"},         {title : "zip files", extensions : "zip"},         {title : "video files", extensions : "mov,mp4,mpeg,avi,mpg,wmv,w4v,flv,ogv,divx,asf,asx,ram,m2v"},                                                               {title : "pdf files", extensions : "pdf"},                                          {title : "text files", extensions : "htm,html,doc,txt,rtf,ppt"}     ],}, } );  uploader.init();    uploader.bind('filesadded', function(up, files) { var html = ''; plupload.each(files, function(file) {     html += '<li id="' + file.id + '">' + file.name + '     ('+plupload.formatsize(file.size) + ') <b></b></li>'; }); document.getelementbyid('filelist').innerhtml += html; });  uploader.bind('fileuploaded', function(up, file, info) {             // called when file has finished uploading             log('[fileuploaded] file:', file, "info:", info);         });   uploader.bind('chunkuploaded', function(up, file, info) {    // called when file chunk has finished uploading   log('[chunkuploaded] file:', file, "info:", info); });  uploader.bind('uploadprogress', function(up, file) { document.getelementbyid(file.id).getelementsbytagname('b')[0].innerhtml = '<span>' + file.percent + "%</span>"; log('[uploadprogress] file:', file, "info:", info); });  uploader.bind('uploadcomplete', function(up, files) {             // called when file has finished uploading              // console.log("[uploadcomplete]");             // backbuttonstate = true;             var totup = uploader.total.uploaded + 1;             var fillen =  uploader.files.length;              if(totup == fillen)             {                 var mypi = "<?php  echo $projid; ?>";                 window.location = "addimg.php?file="+files+"&blid="+mypi;                }            log('[uploadcomplete]');             });  uploader.bind('error', function(up, err) { document.getelementbyid('console').innerhtml += "\nerror #" + err.code +   ": " + err.message; log('[error] file:', file, "info:", err.message); });  document.getelementbyid('start-upload').onclick = function() { uploader.start();        };  function log() {     var str = "";      plupload.each(arguments, function(arg) {         var row = "";          if (typeof(arg) != "string") {             plupload.each(arg, function(value, key) {                 // convert items in file objects human readable form                 if (arg instanceof plupload.file) {                     // convert status human readable                     switch (value) {                         case plupload.queued:                             value = 'queued';                             break;                          case plupload.uploading:                             value = 'uploading';                             break;                          case plupload.failed:                             value = 'failed';                             break;                          case plupload.done:                             value = 'done';                             break;                     }                 }                  if (typeof(value) != "function") {                     row += (row ? ', ' : '') + key + '=' + value;                 }             });              str += row + " ";         } else {             str += arg + " ";         }     });      var log = document.getelementbyid('console');     log.innerhtml += str + "\n"; }   </script>  

try way:

uploader.bind('uploadcomplete', function(up, files) {     // called when files either uploaded or failed      var mypi = "<?php  echo $projid; ?>";     window.location = "addimg.php?file="+files+"&blid="+mypi;         /* not necessary since uploadcomplete means done!      var totup = uploader.total.uploaded + 1;     var fillen =  uploader.files.length;     if(totup == fillen) {}     log('[uploadcomplete]');*/  }); 

and remove php line:

header("location: addimg.php?file=" . $filename . "&blid=" . $mypi); 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -