<?php  //多角度图片修改 /*小图*/
							//多角度图片修改
							for ($i = 0; $i < count($_FILES['newimage']['name']); $i++) {
								$image = $_FILES['newimage']['name'][$i];
								$size = $_FILES['newimage']['size'][$i];
								$type = $_FILES['newimage']['type'][$i];
								if(!$image)
								{
									continue;
								}
								if ($type == "image/gif" || $type == "image/png" || $type == "image/x-png" || $type == "image/pjpeg" || $type == "image/jpeg") {
									if ($size < $PicSize) 
									{


										$products_sql = "select * from ls_propic where productID=" . $id . " && num=" . ($i+1) . " ";

										$products_query = $opendb->query($products_sql);

										$products_rows = mysqli_fetch_assoc($products_query);

										$pic = $products_rows['picName'];

										$pathBigPic = $pathFoldersProducts . "/" . $newBigFoldersProducts;

										//echo $pathBigPic."<br>";

										$pathSmallPic = $pathFoldersProducts . "/" . $newSmallFoldersProducts;

										$oldbigpic = $pathBigPic . "/" . $products_rows[picName];
										while (is_file($oldbigpic) == TRUE) {
											chmod($oldbigpic, 0666);
											
											unlink($oldbigpic);
										}
										//unlink($oldbigpic);		//delete old big pic
										$oldsmallpic = $pathSmallPic . "/" . $products_rows[picName];
										while (is_file($oldsmallpic) == TRUE) {
											chmod($oldsmallpic, 0666);
											 
											unlink($oldsmallpic);
										}

										//unlink($oldsmallpic);	//delete old small pic

										$arr = array(" ", ".");
										//产生文件名   
										$pic = substr($pic, 0, (strlen($pic) - 4));
										//echo $pic;
										$productPic = $pic . "." . substr($image, -3);

										$pathBigPic = $pathBigPic . "/" . $productPic;
										//上传文件
										move_uploaded_file($_FILES['newimage']['tmp_name'][$i], $pathBigPic);

										$toW = $BigPicW;   //宽度

										$toH = $BigPicH;   //高度

										$toFile = $pathBigPic;  //目标地址
										
										//echo "<h1>".$toFile;

										$srcFile = $pathBigPic; //源地址

										$picPath = $toFile;

										ImageResize($srcFile, $toW, $toH, $toFile); //resize the big pic width & height to stand size

										chmod($toFile, 0644);

										//判断是否有图片的备份文件，如果有同时也更新图片的备份文件
// 							if(file_exists($pathBigPic)){
// 								copy($pathBigPic,$pathBigPic.".bak");
// 							}

										$srcFile = $pathBigPic; //源地址

										$toW = $SmallPicW;   //宽度

										$toH = $SmallPicH;   //高度

										$toFile = $pathSmallPic . "/" . $productPic; //目标地址

										$thumbPicPath = $toFile;

										ImageResize($srcFile, $toW, $toH, $toFile);  //生成缩略图

										chmod($toFile, 0644);

										$update_pic_sql = sprintf("update ls_propic set picName=%s,picPath=%s,thumbPicPath=%s,proTitle=%s where productID=%s && num=%s", GetSQLValueString($productPic, "text"), GetSQLValueString($picPath, "text"), GetSQLValueString($thumbPicPath, "text"),GetSQLValueString($_POST['proTitle'][$i], "text"), GetSQLValueString($id, "int"), GetSQLValueString($i+1, "int")
										);
										$update_query = $opendb->query($update_pic_sql);
										//echo $update_pic_sql;
										//exit();
									} else {

										echo "	<script>alert('图像最大为" . $PicSize . "！');history.go(-1);</script>";
										break;
									}
								}

 					else
 					{
 						echo "	<script>alert('请选择图片上传，或者你选择的文件不符合要求!\\n只允许格式 .gif .png .jpeg');history.go(-1);</script>";
						break;
 					}
				}
							//多角度图片修改end
?>
