Example of submitting a vue axios form to upload images,

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.