JavaScript Post Request w/ Image

2019-07-25 00:57发布

问题:

I'm afraid I might know the answer to this already. I'm hoping to present an HTML5 form offline in which a user can select an Image to upload. Once the user gets back on line the image will be uploaded. I can extract all the data from the file input, but is there a way to send the data via post to save the blob on the server?

I'm using jQuery and have a Rails backend (typical fileuploads are handled through CarrierWave).

回答1:

You can create online event and call submit() on form that has your file image.

  • http://www.javascript-coder.com/javascript-form/javascript-form-submit.phtml
  • http://api.jquery.com/submit/