Django JQuery Ajax File Upload

后端 未结 3 1194
猫巷女王i
猫巷女王i 2020-11-27 16:03

I\'ve been trying to upload a simple text file for hours now but I still can\'t seem to get it working.

I keep getting invalid forms saying I\'m missing the \"file_s

3条回答
  •  日久生厌
    2020-11-27 16:48

    You can't use jQuery to upload files asynchronously. You options are:

    1.Submit the form "the usual way". This, of course, will refresh the page.

    2.Use XHR: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest but beware that it's not supported on IE 8/9 . On those browsers you would need to fall back to an iframe and a form that posts to it, to mimic an asynchronous upload.

    3.Use https://github.com/blueimp/jQuery-File-Upload It does what I described in 2. but spares you all the configuring.

提交回复
热议问题