javascript - The overall process of uploading files from the front end to the backend
巴扎黑
巴扎黑 2017-05-27 17:41:56
0
4
575

It’s like this. What I want to ask is, when uploading files, don’t you use the form to upload them? Why use a plug-in? For example, jquery_form_min
can't upload directly via ajax? ?

巴扎黑
巴扎黑

reply all (4)
阿神

In most cases, we will try our best to allow users to complete basic image processing operations on the current page. This can be discussed from some practical needs and user experience.
In the past, everyone thought that using AJAX could achieve refresh-free uploading, but it was very difficult to practice (you can practice this yourself, but there are pitfalls everywhere...), usually we need the attributes ofform标签添加一个enctype="multipart/form-data"to achieve the image Upload, in fact, AJAX cannot handle the data we submit very well, so in order not to repeat the early rounds, we use some ready-made upload plug-ins (for example, you usually do not develop a visual editor for a new project, or a set of development software).
Also, don’t you think it’s too heavy a burden to have a form process both regular data and image data? What's more, if there are multiple places where upload needs to be used, will there be too much overlap in your code?

    PHPzhong

    ajax is enough, just put the file in the upload data parameter, but you didn't explain it clearly enough.

      某草草

      Excluding flash, generally upload using the form form. If you need to support some older browsers, you can use the form embedded in HTML to implement submission. If you need asynchronous implementation, you can use iframe. If you do not need to support older browsers, you can use formdata+ajax to implement asynchronous submission. As for why components are used, it is to achieve code reuse, avoid reinventing the wheel, and improve development efficiency. You can refer to http://www.ruanyifeng.com/blo...

        黄舟

        I use webuploader, which can automatically upload and button upload, multi-file upload, drag and drop upload~~ But I have not tried to submit it together with the form data. After submitting the file, I return the file path in the background, and then put the path Submitted with the form.

          Latest Downloads
          More>
          Web Effects
          Website Source Code
          Website Materials
          Front End Template
          About us Disclaimer Sitemap
          php.cn:Public welfare online PHP training,Help PHP learners grow quickly!