php批量上传三[带预览]_PHP教程
程序员文章站
2024-04-04 12:30:53
...
if($_POST['upload']=='提交'){
//*******************************************************
//**批量上传**********************************************
function saveImage ($im , $filename)
{
$r = imagejpeg ($im , $filename);
if($r){
echo "";
}
else{
echo "";
}
}
function Makesuo ($img_path,$img_name,$img_type)
{
$open_file = $img_path.$img_name;
$file_type = $img_type;
if($file_type == "jpg"){
$source = imagecreatefromjpeg($open_file);
}
elseif($file_type == "gif"){
$source = imagecreatefromgif($open_file);
}
elseif($file_type =="png"){
$source = imagecreatefrompng($open_file);
}
$size = getimagesize($open_file);
$size_wei = $size[0];
$size_hei = $size[1];
$pic_bi = $size_wei/$size_hei;
if($pic_bi>1.2){
$new_wei = $size_hei*1.2;
$new_hei = $size_hei;
$loda_point = ($size_wei-$new_wei)/2;
$target1 = imagecreatetruecolor(120,100);
imagecopyresized($target1,$source,0,0,$loda_point,0,120,100,$new_wei,$new_hei);
saveImage($target1, "../suo_img/suo_".$img_name,$file_type);
return "../suo_img/suo_".$img_name;
imagedestroy($source);
imagedestroy($target1);
}
elseif($pic_bi = 1){
$new_wei = $size_hei*1.2;
$new_hei = $size_hei;
$loda_point = ($size_wei-$new_wei)/2;
$target1 = imagecreatetruecolor(120,100);
imagecopyresized($target1,$source,0,0,$loda_point,0,120,100,$new_wei,$new_hei);
saveImage($target1, "../suo_img/suo_".$img_name,$file_type);
return "../suo_img/suo_".$img_name;
imagedestroy($source);
imagedestroy($target1);
}
elseif($pic_bi
$new_hei = $size_wei*1.2;
$new_wei = $size_wei;
$loda_point = ($size_hei-$new_hei)/2;
$target1 = imagecreatetruecolor(120,100);
imagecopyresized($target1,$source,0,0,0,$loda_point,120,100,$new_wei,$new_hei);
saveImage($target1, "../suo_img/suo_".$img_name,$file_type);
return "../suo_img/suo_".$img_name;
imagedestroy($source);
imagedestroy($target1);
}
}
//*******************************************************
//**批量上传**********************************************
function saveImage ($im , $filename)
{
$r = imagejpeg ($im , $filename);
if($r){
echo "";
}
else{
echo "";
}
}
function Makesuo ($img_path,$img_name,$img_type)
{
$open_file = $img_path.$img_name;
$file_type = $img_type;
if($file_type == "jpg"){
$source = imagecreatefromjpeg($open_file);
}
elseif($file_type == "gif"){
$source = imagecreatefromgif($open_file);
}
elseif($file_type =="png"){
$source = imagecreatefrompng($open_file);
}
$size = getimagesize($open_file);
$size_wei = $size[0];
$size_hei = $size[1];
$pic_bi = $size_wei/$size_hei;
if($pic_bi>1.2){
$new_wei = $size_hei*1.2;
$new_hei = $size_hei;
$loda_point = ($size_wei-$new_wei)/2;
$target1 = imagecreatetruecolor(120,100);
imagecopyresized($target1,$source,0,0,$loda_point,0,120,100,$new_wei,$new_hei);
saveImage($target1, "../suo_img/suo_".$img_name,$file_type);
return "../suo_img/suo_".$img_name;
imagedestroy($source);
imagedestroy($target1);
}
elseif($pic_bi = 1){
$new_wei = $size_hei*1.2;
$new_hei = $size_hei;
$loda_point = ($size_wei-$new_wei)/2;
$target1 = imagecreatetruecolor(120,100);
imagecopyresized($target1,$source,0,0,$loda_point,0,120,100,$new_wei,$new_hei);
saveImage($target1, "../suo_img/suo_".$img_name,$file_type);
return "../suo_img/suo_".$img_name;
imagedestroy($source);
imagedestroy($target1);
}
elseif($pic_bi
$new_hei = $size_wei*1.2;
$new_wei = $size_wei;
$loda_point = ($size_hei-$new_hei)/2;
$target1 = imagecreatetruecolor(120,100);
imagecopyresized($target1,$source,0,0,0,$loda_point,120,100,$new_wei,$new_hei);
saveImage($target1, "../suo_img/suo_".$img_name,$file_type);
return "../suo_img/suo_".$img_name;
imagedestroy($source);
imagedestroy($target1);
}
}
上一篇: php WEB上创建网站_PHP教程
下一篇: 解刨mvc中pathinfo路由解析原理