 <!-- saveproducts 中 update 的 insert 新插入多角度图片  -->
 
 <?
				/* propic插入新上传产品数据 */

						$sql="SELECT * 
						FROM `ls_propic` 
						WHERE `productID` =$id
						ORDER BY num DESC 
						LIMIT 1 ";
						$query=$opendb->query($sql);
						$rows=mysql_fetch_assoc($query);
						$num=$rows[num];	
					
						for ($i = 0; $i < count($_FILES['showPic']['name']); $i++) {
								$image = $_FILES['showPic']['name'][$i];
								$size = $_FILES['showPic']['size'][$i];
								$type = $_FILES['showPic']['type'][$i];
								$text = $_POST['text'][$i];

								if ($text == null) {
									$text = "ls";
								}

							if(!$image){
											continue;

										}	
										
								if ($type == "image/gif" || $type == "image/png" || $type == "image/x-png" || $type == "image/pjpeg" || $type == "image/jpeg") {
									if ($size < $PicSize) {
										
										$pathBigPic = $pathFoldersProducts . "/" . $newBigFoldersProducts;
										createFolder($pathBigPic);	    //创建图片上传目录
										$pathSmallPic = $pathFoldersProducts . "/" . $newSmallFoldersProducts;
										createFolder($pathSmallPic);	  //创建小图文件夹
										$pathPagePic = $pathFoldersProducts . "/" . $showproductsFolders;
										createFolder($pathPagePic);	  //创建大图浏览（.htm）文件夹
										$arr = array(" ", ".");
										$productPic = str_replace($arr, "", time()) . $i . "." . substr($image, -3);
										$pathBigPic = $pathBigPic . "/" . $productPic;
										move_uploaded_file($_FILES['showPic']['tmp_name'][$i], $pathBigPic);
										chmod($pathBigPic, 0644);
										$toW = $BigPicW;   //宽度
										$toH = $BigPicH;   //高度
										$toFile = $pathBigPic; //目标地址
										$srcFile = $pathBigPic; //目标地址
										ImageResize($srcFile, $toW, $toH, $toFile); //resize the big pic width & height to stand size
										chmod($toFile, 0644);
										$srcFile = $pathBigPic; //源地址
										$toW = 80;   //宽度
										$toH = 80;   //高度
										$toFile = $pathSmallPic . "/" . $productPic; //目标地址
										$thumbPicPath = $toFile;
										ImageResize($srcFile, $toW, $toH, $toFile);
										chmod($toFile, 0644);
										$nu=$num+$i+1;
										$insert_sql = sprintf("insert into ls_propic (productID,picName,picPath,thumbPicPath,num,proTitle,enable) values (%s,%s,%s,%s,%s,%s,%s) ", GetSQLValueString($id, "int"), GetSQLValueString($productPic, "text"), GetSQLValueString($pathBigPic, "text"), GetSQLValueString($thumbPicPath, "text"), GetSQLValueString($nu, "int"), GetSQLValueString($text, "text"), GetSQLValueString("1", "int")
										);

										$insert_query = $opendb->query($insert_sql);
									}
								}
						}
								//上传局部图片
									$bigimage=$_POST[bigimage];
									$sql="SELECT * 
									FROM `partimages` 
									WHERE `bigimage` = '".$bigimage."'
									LIMIT 1 ";
									$query=$opendb->query($sql);
									$rows=mysql_fetch_assoc($query);
									$num=$rows[num];	
									for ($e = 0; $e < count($_FILES['partimages']['name']); $e++) {
										$image = $_FILES['partimages']['name'][$e];
										$size = $_FILES['partimages']['size'][$e];
										$type = $_FILES['partimages']['type'][$e];
										$partText = $_POST['partText'][$e];
										$partText == null ? $partText = "ls" : $partText = $partText;
										if(!$image){
											continue;

										}
										if ($type == "image/gif" || $type == "image/png" || $type == "image/x-png" || $type == "image/pjpeg" || $type == "image/jpeg") {
											if ($size < $PicSize) {
												$id = $_POST['id'];
												$select_sql2 = "select * from ls_propic where productID='" . $productID . "' && num='0' ";
												$result = $opendb->query($select_sql2);
												$rows = mysql_fetch_assoc($result);
												$picname = $rows['picName'];   //最后更新的图片名称


												$pathBigPic = $pathFoldersProducts . "/" . $partImagesFolders;
												createFolder($pathBigPic);	    //创建图片上传目录



												$arr = array(" ", ".");

												$productPic = str_replace($arr, "", time()) . $e . "." . substr($image, -3);

												$pathBigPic = $pathBigPic . "/" . $productPic;


												move_uploaded_file($_FILES['partimages']['tmp_name'][$e], $pathBigPic);
												
												chmod($pathBigPic, 0644);

												$toW = 100;   //宽度

												$toH = 100;   //高度

												$toFile = $pathBigPic; //目标地址

												$srcFile = $pathBigPic; //源地址
												ImageResize($srcFile, $toW, $toH, $toFile);

												chmod($toFile, 0644);



									if($bigimage){

												$insert_sql = sprintf("INSERT INTO partimages (`bigimage`, `partImages`, `partImagesPath`, `num`, `describe`, `enable`) VALUES (%s, %s, %s, %s, %s, %s)", GetSQLValueString($bigimage, "text"), GetSQLValueString($productPic, "text"), GetSQLValueString($pathBigPic, "text"), GetSQLValueString($e+$num, "int"), GetSQLValueString($partText, "text"), GetSQLValueString("1", "int")
												);

												$insert_query = $opendb->query($insert_sql);
											}else{
											$insert_sql = sprintf("INSERT INTO partimages (`bigimage`, `partImages`, `partImagesPath`, `num`, `describe`, `enable`) VALUES (%s, %s, %s, %s, %s, %s)", GetSQLValueString($picname, "text"), GetSQLValueString($productPic, "text"), GetSQLValueString($pathBigPic, "text"), GetSQLValueString($e+$num, "int"), GetSQLValueString($partText, "text"), GetSQLValueString("1", "int")
												);

												$insert_query = $opendb->query($insert_sql);	
											}
										}
									}
									}
									
								
 ?>
