此处一次支持上传2个图片,上传后生成原图和质量较差的图,原图用于保存质量高的图片,质量差的图用于网页显示。
PHP Code
<div class="codetitle"><a style="CURSOR: pointer" data="5932" class="copybut" id="copybut5932" onclick="doCopy('code5932')"> 代码如下:
此处一次支持上传2个图片,上传后生成原图和质量较差的图,原图用于保存质量高的图片,质量差的图用于网页显示。
PHP Code
<div class="codetitle"><a style="CURSOR: pointer" data="5932" class="copybut" id="copybut5932" onclick="doCopy('code5932')"> 代码如下:
i','',$_FILES['work1']['name']); <BR>$work1 = $target_name; <BR>$target = dirname(__FILE__).'/uploads/'.$target_name; <BR>switch($type) <BR>{ <BR>case "image/jpeg": <BR>$resultImage = imagecreatefromjpeg($original); <BR>imagejpeg($resultImage,$target,$quality); <BR>break; <BR>case "image/png": <BR>$resultImage = imagecreatefrompng($original); <BR>imagepng($resultImage,$quality_png); <BR>break; <BR>case "image/gif": <BR>$resultImage = imagecreatefromgif($original); <BR>imagegif($resultImage,$quality); <BR>break; <BR>default : <BR>die("<a href="https://www.jb51.cc/tag/buzhichi/" target="_blank" class="keywords">不支持</a>此<a href="https://www.jb51.cc/tag/wenjian/" target="_blank" class="keywords">文件</a>类型"); <BR>exit; <BR>} <BR>$work1_small = $target_name; <BR>$target = dirname(__FILE__).'/uploads/small/'.$target_name; <BR>switch($type) <BR>{ <BR>case "image/jpeg": <BR>$resultImage = imagecreatefromjpeg($original); <BR>imagejpeg($resultImage,$quality2); <BR>break; <BR>case "image/png": <BR>$resultImage = imagecreatefrompng($original); <BR>imagepng($resultImage,$quality2_png); <BR>break; <BR>case "image/gif": <BR>$resultImage = imagecreatefromgif($original); <BR>imagegif($resultImage,$quality2); <BR>break; <BR>default : <BR>die("<a href="https://www.jb51.cc/tag/buzhichi/" target="_blank" class="keywords">不支持</a>此<a href="https://www.jb51.cc/tag/wenjian/" target="_blank" class="keywords">文件</a>类型"); <BR>exit; <BR>} <BR>} <BR>if(isset($_FILES['work2']) && $_FILES['work2']['error']==0) <BR>{ <BR>$size = getimagesize($_FILES['work2']['tmp_name']); <BR>$original = $_FILES['work2']['tmp_name']; <BR>$type = $_FILES['work2']['type']; <BR>$target_name = date('YmdHis').'_'.preg_replace('
[^a-z0-9-_.]`i',$_FILES['work2']['name']);