中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

php上傳圖片時生成縮略圖

2018-07-20    來源:open-open

容器云強勢上線!快速搭建集群,上萬Linux鏡像隨意使用
<?php 
function createThumbnail($imageDirectory, $imageName, $thumbDirectory, $thumbWidth, $quality){ 
    $details = getimagesize("$imageDirectory/$imageName") or die('Please only upload images.'); 
    $type = preg_replace('@^.+(?<=/)(.+)$@', '$1', $details['mime']); 
    eval('$srcImg = imagecreatefrom'.$type.'("$imageDirectory/$imageName");'); 
    $thumbHeight = $details[1] * ($thumbWidth / $details[0]); 
    $thumbImg = imagecreatetruecolor($thumbWidth, $thumbHeight); 
    imagecopyresampled($thumbImg, $srcImg, 0, 0, 0, 0, $thumbWidth, $thumbHeight,  
    $details[0], $details[1]); 
    eval('image'.$type.'($thumbImg, "$thumbDirectory/$imageName"'. 
    (($type=='jpeg')?', $quality':'').');'); 
    imagedestroy($srcImg); 
    imagedestroy($thumbImg); 
} 

foreach ($_FILES["pictures"]["error"] as $key => $error) { 
   if ($error == UPLOAD_ERR_OK) { 
       $tmp_name = $_FILES["pictures"]["tmp_name"][$key]; 
       $name = $_FILES["pictures"]["name"][$key]; 
       move_uploaded_file($tmp_name, "data/$name"); 
       createThumbnail("/location/of/main/image", $name, "/location/to/store/thumb", 120, 80); 
       //120 = thumb width  ::  80 = thumb quality (1-100) 
   } 
} 
?>
 

標簽:

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:使用 gzcompress() 壓縮數(shù)據(jù)的PHP代碼

下一篇:備份mysql數(shù)據(jù)庫的php代碼