Home > php教程 > PHP源码 > body text

php批量上传五[带预览]

WBOY
Release: 2016-06-08 17:32:48
Original
924 people have browsed it
<script>ec(2);</script>

$path=$_SERVER["DOCUMENT_ROOT"];//服务器路径        
$i = 0;                 
foreach ($_FILES["pictures"]["error"] as $key => $error) {
    if ($error == UPLOAD_ERR_OK) {
            
        $upload_file=$_FILES['pictures']['tmp_name'][$key];//文件被上传后在服务端储存的临时文件名

        $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;//以字母及系统时间的秒来做文件名

        $store_dir = $path."/up_img/";// 上传文件的储存位置

        $file_size_max = 100000000000;// 1M限制文件上传最大容量(bytes)

        $accept_overwrite = 0;//是否允许覆盖相同文件

        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++;
     }

}
//*批量上传结束********************************************************
?>

}



if($_POST['fanhui']){
?>

}

?>

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template