问题描述:
在godaddy空间,出现ecshop相册无法生成,经调试发现是 function move_image_file 内部copy函数出错 ,纠结原因是目标目录内文件过多,修改 reformat_image_name 让再分出一个目录来安置图片
function reformat_image_name($type, $goods_id, $source_img, $position='') { $rand_name = gmtime() . sprintf("%03d", mt_rand(1,999)); $img_ext = substr($source_img, strrpos($source_img, '.')); $dir = 'images'; if (defined('IMAGE_DIR')) { $dir = IMAGE_DIR; } $sub_dir = date('Ym', gmtime()); if (!make_dir(ROOT_PATH.$dir.'/'.$sub_dir)) { return false; } if (!make_dir(ROOT_PATH.$dir.'/'.$sub_dir.'/source_img')) { return false; } if (!make_dir(ROOT_PATH.$dir.'/'.$sub_dir.'/goods_img')) { return false; } if (!make_dir(ROOT_PATH.$dir.'/'.$sub_dir.'/goods_img_2')) { return false; } if (!make_dir(ROOT_PATH.$dir.'/'.$sub_dir.'/thumb_img')) { return false; } if (!make_dir(ROOT_PATH.$dir.'/'.$sub_dir.'/thumb_img_2')) { return false; } switch($type) { case 'goods': $img_name = $goods_id . '_G_' . $rand_name; break; case 'goods_thumb': $img_name = $goods_id . '_thumb_G_' . $rand_name; break; case 'gallery': $img_name = $goods_id . '_P_' . $rand_name; break; case 'gallery_thumb': $img_name = $goods_id . '_thumb_P_' . $rand_name; break; } if ($position == 'source') { if (move_image_file(ROOT_PATH.$source_img, ROOT_PATH.$dir.'/'.$sub_dir.'/source_img/'.$img_name.$img_ext)) { return $dir.'/'.$sub_dir.'/source_img/'.$img_name.$img_ext; } } elseif ($position == 'thumb') { if (move_image_file(ROOT_PATH.$source_img, ROOT_PATH.$dir.'/'.$sub_dir.'/thumb_img/'.$img_name.$img_ext)) { return $dir.'/'.$sub_dir.'/thumb_img/'.$img_name.$img_ext; }else{ if (move_image_file(ROOT_PATH.$source_img, ROOT_PATH.$dir.'/'.$sub_dir.'/thumb_img_2/'.$img_name.$img_ext)) { return $dir.'/'.$sub_dir.'/thumb_img_2/'.$img_name.$img_ext; } } } else { if (move_image_file(ROOT_PATH.$source_img, ROOT_PATH.$dir.'/'.$sub_dir.'/goods_img/'.$img_name.$img_ext)) { return $dir.'/'.$sub_dir.'/goods_img/'.$img_name.$img_ext; }else{ if (move_image_file(ROOT_PATH.$source_img, ROOT_PATH.$dir.'/'.$sub_dir.'/goods_img_2/'.$img_name.$img_ext)) { return $dir.'/'.$sub_dir.'/goods_img_2/'.$img_name.$img_ext; } } } return false; }
上面代码中 goods_img_2 和 thumb_img_2 就是转存目录