javascript - ajax image file submitted together with text box data for upload processing
迷茫2017-05-31 10:41:10
0
1
616
Select a local image file, enter some data in the input box and click Submit. After submission, an Uncaught TypeError: Illegal invocation error will be reported directly. Illegal call, the file cannot be used forData and cannot be placed in json
If you want to submit the file using ajax, there are basically three ways 1. You can encapsulate your file with formdata, and then put in the ajax data. 2. You can use the jquery from plug-in to upload Wenjia directly. 3. You can convert local files into base64 format, and then submit them in the same way as ordinary text formats. Then convert base64 to an image on the server side.
If you want to submit the file using ajax, there are basically three ways
1. You can encapsulate your file with formdata, and then put in the ajax data.
2. You can use the jquery from plug-in to upload Wenjia directly.
3. You can convert local files into base64 format, and then submit them in the same way as ordinary text formats. Then convert base64 to an image on the server side.