1

I need to get a url to redirect to from the server (using Flask) after some files are done uploading so I can redirect to it. I can't use flask for this because it simply is not working, and trying to redirect after POSTing large or multiple files using server side redirects apparently is some kind of browser issue. I'm trying to throw a URL back to the JS, which will do the redirect after it checks all files are uploaded. JS is in a separate file from the HTML, but the url:of the dropzone is passed to it through a small inline script. The function in JS I'm trying to use to get the response looks like this:

this.on("complete", function(responseText) {
      if (this.getQueuedFiles().length == 0 && this.getUploadingFiles().length == 0) {
        window.location.href = responseText;

      }


    });

It does the redirect but instead of the URL that Flask should have been returning (and I know it is) I get the url I was on previously + [object File]on the end, which obviously Flask throws an error for because it isn't a real URL. The JS uploader I'm using is Dropzone.js, which doesn't use jQuery or anything like that, what am I doing wrong? I'm new to JS and just confused by all this AJAX/JSON/jQuery stuff, is there an easy way to do this?

jack
  • 147
  • 3
  • 13
  • try printing the value of `responseText` on the console using `console.log(responseText)`. you can comment the `window.location.href` line so you can see the output :) – anurupr Mar 08 '14 at 08:45

1 Answers1

0

If you want to achieve redirect after upload completed by pure Dropzone.js, please check out my answer here. Otherwise, you can use Flask-Dropzone, a Flask extension that integrates Dropzone.js with Flask. For this issue, you can set DROPZONE_REDIRECT_VIEW to the view you want to redirect when uploading complete.

Grey Li
  • 11,664
  • 4
  • 54
  • 64