Example of submitting a vue axios form to upload images,
The element framework used in the project, and the requirement for adding data in the project is that images can be uploaded or not uploaded,
The problem is that the upload control in the element does not trigger the submission when there is no image, but the interface writes the multipart/form-data receiving mode with file.
Only one form can be imitated by the other.
<Input class = "file" name = "file" type = "file" accept = "image/png, image/gif, image/jpeg" @ change = "update"/>
Let file = e.tar get. files [0]; let param = new FormData (); // create the form object param. append ('file', file, file. name); // Add data param to the form object through append. append ('chunk', '0'); // Add other data in the form let config = {headers: {'content-type ': 'multipart/form-data'}; // Add the request header this. axios. post ('HTTP: // upload.qiniu.com/', param,config ). then (response => {console. log (response. data );})
The above example of submitting and uploading images in the vue axios form is all the content shared by Alibaba Cloud xiaobian. I hope you can give us a reference and support for the help house.