PHP Simple file image bulk upload program code _php tutorial

Source: Internet
Author: User
The bulk upload method is also very simple we just add a name=\ "pictures[]\" array to the form, and then use the foreach ($_files[\ "pictures\"][\ "error\"] as $key = $error) The Move_uploaded_file ($tmp _name, $uploadfile) were used to determine the cyclic array. Implement the file upload is possible.

HTML code

The code is as follows Copy Code

Upload picture More once

PHP Processing Code

copy code

"!--? php

If ($_post[' upload ']= = ' Send ') {

$dest _folder = "picture/";

If (!file_exists ($dest _folder)) {

mkdir ($dest _folder);

}

foreach ($_files["Pictures" ["Error"] as $key = = $error) {

if ($error = = UPLOAD_ERR_OK) {

$ Tmp_name = $_files["Pictures" ["Tmp_name"] [$key];

$name = $_files["Pictures" ["Name"] [$key];

$uploadfile = $dest _folder. $name;

Move_uploaded_file ($tmp _name, $uploadfile);

}

}

}

?>

The method is quite simple we just changed the single file upload to a multi-file upload, the other only changed to two places one is the table sole name changed to PHP array form one is to upload the file place using foreach to log the group traversal.

http://www.bkjia.com/PHPjc/629142.html www.bkjia.com true http://www.bkjia.com/PHPjc/629142.html techarticle The bulk upload method is also very simple we just add a name=\ "pictures[]\" array to the form, and then use the foreach ($_files[\ "pictures\"][\ "error\"] as $key = $ Error) loop -over the array ...

  • 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.