商品内容不变,只上传图片,会编辑错误,怎么解决?King帅哥老师可不可以帮我们解决一下,我看到大家都有这个问题。
function editPro($id){
$arr=$_POST;
//var_dump($arr);
$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);
}
}
$where="id={$id}";
$res=update("shop_pro",$arr,$where);
$pid=$id;
//var_dump($res);
if($res&&$pid){
if($uploadFiles &&is_array($uploadFiles)){
foreach($uploadFiles as $uploadFile){
$arr1['pid']=$pid;
$arr1['albumPath']=$uploadFile['name'];
addAlbum($arr1);
}
}
$mes="<p>编辑成功!</p><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='listPro.php' target='mainFrame'>重新编辑</a>";
}
return $mes;
}