/**
* 添加商品
* @return string
*/
function addPro(){
$arr=$_POST;
$arr['addtime']=time();
$path="./uploads";
$uploadFiles=uploadFile($path);
if(is_array($uploadFiles)&&$uploadFiles){
foreach($uploadFiles as $key=>$uploadFile){
thumb($path."/".$uploadFile['name'],"../image_50/".$uploadFile['name'],50,50);
thumb($path."/".$uploadFile['name'],"../image_220/".$uploadFile['name'],220,220);
thumb($path."/".$uploadFile['name'],"../image_350/".$uploadFile['name'],350,350);
thumb($path."/".$uploadFile['name'],"../image_800/".$uploadFile['name'],800,800);
}
}
$res=insert("store",$arr);
print_r(res);die; // 插入数据打印的是 0
$pid=getInsertId();
if($res&&$pid){
foreach($uploadFiles as $uploadFile){
$arr1['pid']=$pid;
$arr1['imageAddr']=$uploadFile['name'];
addAlbum($arr1);
}
$mes="<p>添加成功!</p><a href='addPro.php' target='mainFrame'>继续添加</a>|<a href='listPro.php' target='mainFrame'>查看商品列表</a>";
}else{
if(is_array($uploadFiles)&&$uploadFiles){
foreach($uploadFiles as $uploadFile){
if(file_exists("../image_800/".$uploadFile['name'])){
unlink("../image_800/".$uploadFile['name']);
}
if(file_exists("../image_50/".$uploadFile['name'])){
unlink("../image_50/".$uploadFile['name']);
}
if(file_exists("../image_220/".$uploadFile['name'])){
unlink("../image_220/".$uploadFile['name']);
}
if(file_exists("../image_350/".$uploadFile['name'])){
unlink("../image_350/".$uploadFile['name']);
}
}
}
$mes="<p>添加失败!</p><a href='addPro.php' target='mainFrame'>重新添加</a>";
}
return $mes;
}
qq_阿湃_0