PHP allows you to upload multiple images for instant display and instant deletion. php allows you to upload multiple images.

Source: Internet
Author: User

PHP allows you to upload multiple images for instant display and instant deletion. php allows you to upload multiple images.

This example describes how PHP can instantly display and delete multiple images uploaded. We will share this with you for your reference. The details are as follows:

Just like this, each time you select an image, it will be instantly displayed and appended to the right side. You can also delete an element at will.

Actually, when type = file's input box's onchange event === "post data is submitted to the hidden ifram (specified by the target of form) ===" receives the direct echo script tag of post data to return data to the front-end page and assign values, and then stores the image path in a hidden domain:

HTML:

<! Doctype html> 

Controller(Return the path of the selected image (uploaded) on the server ):

Public function submitimg () {if (IS_POST) {$ data = I ('Post. data '); // get post data $ res = fab_upload ($ _ FILES); // upload a file $ uid = uniqid (); $ res = $ res ['thumb']; if ($ res) {echo "<script> parent. callblack_img ('{$ res}', '{$ uid}'); </script> ";}}}

Functions that actually receive form data and store it in the database:

public function add_journal(){     if(IS_POST){         var_dump($_POST);die;       }else{        $this->display();     }}

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.