PHP Batch upload five [with preview]

Source: Internet
Author: User

$path =$_server["document_root"];//server path
$i = 0;
foreach ($_files["Pictures"] ["error"] as $key => $error) {
if ($error = = UPLOAD_ERR_OK) {

$upload _file=$_files[' pictures ' [' tmp_name '] [$key the temporary filename stored in the server after the];//file was uploaded

$imgtype = Strtolower (strrchr ($_files[' pictures '] [' name '] [$key], ".");

$name _1 = Strtolower (substr ($_files["Pictures"] ["name"] [$key],0,2)];

$upload _file_name= "Lanmayi_". Time () $name _1. $imgtype//file name in seconds of Alphabet and system times

$store _dir = $path. " /up_img/";//upload file storage location

$file _size_max = 100000000000;//1M limit file upload maximum capacity (bytes)

$accept _overwrite = 0;//whether to allow overwriting of the same file

Move_uploaded_file ($upload _file, $store _dir. $upload _file_name);

$new _img_name = $upload _file_name;

$new _img_type = substr ($imgtype, 1, 3);

$new _img_path = $store _dir;

$suo _name = Makesuo ($new _img_path, $new _img_name, $new _img_type);

$sh _time = Date (' y-m-d h:i:s ');

$name = $_post[' name '];

$pid = $id;

$sql = "INSERT into Lanmayi_img_show (pid,sh_name,sh_url,sh_suo,sh_time) VALUES (". $pid. ", '". $name [$i]. $upload _ file_name. "', '". $suo _name "', '" "$sh _time." ') ";

$res = Mysqli_query ($conn, $sql);

$i + +;
}

}
* Bulk upload End ********************************************************
?>
<script language= "JavaScript" >
Alert ("Image upload success!") ")
</script>
<?php
}



if ($_post[' Fanhui ']) {
?>
<script language= "JavaScript" >
Window.location= ' pro_list.php?id=<?php echo $id?> ';
</script>
<?php
}

?>

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.