How to setup for jQuery-File-Upload? How to implement the upload handler?


I am new on Javascript. However I want to implement the jquery plugin for File uploading.

Here is the setup guide I found but I have no basic knowledge on how to setup this.

I am using python (flask) as my server side implementation

From the setup guide heading,

Using jQuery File Upload (UI version) with a custom server-side upload handler

I have no idea on how to setup point 1, 4, 5

for 1, what is a upload handler? and how to implement in python (flask)?

for 4, what doses "Upload the jQuery-File-Upload folder to your website."??? what is it use for?

and for 5, I have to return a JSON response on the upload handler? Why we have to do that?

The setup is quite complicated...anyone can give me some hints?


3/23/2012 7:59:26 AM

Accepted Answer

Maybe one or two hints:

  1. The upload handler is simply a URL endpoint that the jQuery File Upload can send files to - it needs to be able to handle incoming HTTP requests.

    @app.route("/uploads", methods=["GET", "POST"])
    def upload_handler():
        # Handle the upload here
  2. You don't need to upload the entire folder - only the CSS and JavaScript you will be using. If you only need file uploading your template could look like the basic setup. (However, you should minify and concatenate your files for a deployed website).

  3. You return a JSON response to the upload handler so that the script handler performing the XHR file upload request can know things like:

    • What the URL for the uploaded image is (and the thumbnail, if you are making thumbnails).
    • What the delete URL (and method) is.

The linked example for Flask seems very similar to the Django example for the new version - you can probably start with that and then patch it to work with the new version of jQuery file upload.

3/24/2012 3:54:53 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow