File Upload in PHP: A file upload button and a Save button

Source: Internet
Author: User
One browse (that is, selecting a file but not uploading) and one save (click this to upload ). How to write this business logic? Because the files are automatically uploaded after the file is selected, the "save" button is broken.

One browsing (that is, selecting a file but not uploading it)
Save one (click to upload ).

How to write this business logic? Because the files are automatically uploaded after the file is selected, the "save" button is broken.

Reply content:

One browsing (that is, selecting a file but not uploading it)
Save one (click to upload ).

How to write this business logic? Because the files are automatically uploaded after the file is selected, the "save" button is broken.

  • You can configure the plug-in.

  • If you write it yourself, select the image and do not allow him to request the interface.

Image preview. This is mainly done at the front end. When you click Save, you can submit the content to the server. For details, refer
Https://github.com/zp1996/myUpload/blob/master/upload.js

The statement is missing.
The jquery uploadify plug-in is used. It has an upload success callback address parameter uploadsuccess.
I'm wondering how to handle it more securely.

Supplement:
I am thinking that the user has uploaded the image, but has not saved the path to the database, and then the user has changed the image.
In this case, can I only write a shell script to regularly delete images in the upload directory?

After selecting an image for browsing, the image has actually been uploaded to the server. The returned server address is in a hidden form. When you click Submit, bind the image to the user.

This part is involved in the project.
Preview can be solved directly at the front end

$ (Upload file Input ). change (function () {var file = this. files [0]; var r = new FileReader (); r. readAsDataURL (file); $ (r ). load (function () {// The key lies in this. result (selector).html(''background .css ('background ', 'url (' + this. result + ')');})});

After previewing, I used Ajax to upload images.

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.