www.gusucode.com > PHP批量上传图片在线生成图库、相册PHP源码程序 > PHP批量上传图片在线生成图库、相册/uploadpic/uploadpic/AddPicprocess.php
<?php header("Content-type: text/html;charset=utf-8"); require 'connect.php'; $conn=new SqlTool(); $albumid=$_POST['albumid'];//相册编号 $albumname=$_POST['albumname'];//相册名称 $depict=$_POST['depict']; $dateline=date("Y-m-d H:i:m"); $dest_folder = "picture/"; $upcount=0; if(!file_exists($dest_folder)) { if(mkdir($dest_folder)) { }//end of if(mkdir($dest_folder)) else { echo"创建文件夹失败<br/>"; } } //end of if(!file_exists($dest_folder)) foreach ($_FILES["pictures"]["error"] as $key => $error ) { $i=0; if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["pictures"]["tmp_name"][$key]; $name = $_FILES["pictures"]["name"][$key]; $uploadfile = $dest_folder.$name; $filepath="../nongxiaotushu/Manage/pic/"; $filepath=$filepath.$uploadfile; move_uploaded_file($tmp_name, $uploadfile); $sql="INSERT INTO `nongxiaotushu3`.`pre_pic` (`albumid`, `dateline`,`depict`,`filepath` ) VALUES ( '$albumid','$dateline', '$depict[$i]','$filepath')"; $b=$conn->execute_dml($sql); if($b) { //echo"成功"; $i++; $upcount++; //header("location:login.php?errno=2"); } else { echo"失败"; die("失败".mysql_error()); } }//end of if } //end of foreach $sql="select `picnum` from `pre_album` where `albumid`='$albumid'"; $res=$conn->execute_dql($sql); if($row=mysql_fetch_row($res)) { $piccount=$row[0]; $piccount=$piccount+$upcount; $sql="UPDATE `nongxiaotushu3`.`pre_album` SET `picnum`='$piccount' where `pre_album`.`albumid`='$albumid'"; echo"修改相册数量"."$sql<br/>"; $b=$conn->execute_dml($sql); if($b) { // //echo"相册修改成功"; //header("PicManage.php"); } else { die("相册修改失败".mysql_error()); } } else { $sql="INSERT INTO `nongxiaotushu3`.`pre_album` (`albumid`,`albumname`, `dateline`,`picnum`,`pic` ) VALUES ( '$albumid','$albumname','$dateline', $upcount,'$filepath')"; echo "相册添加"."$sql<br/>"; $b=$conn->execute_dml($sql); if($b) { echo"相册添加成功"; echo"$sql<br/>"; //header("location:login.php?errno=2"); } else { // echo"相册添加失败"; die("失败".mysql_error()); } } ?>