蒙狼科技logo
          設為首頁| 聯系我們
          咨詢熱線: 13917498722
            您的位置: 首頁 > 網站資訊 > php SWFUpload 怎么創建縮略圖并且保存

          php SWFUpload 怎么創建縮略圖并且保存

          發布日期:2017/9/3

           

          upload.php   <?php /*  * swfupload圖片上傳    */      if (isset($_POST["PHPSESSID"])) {         session_id($_POST["PHPSESSID"]);     }     session_start();     ini_set("html_errors", "0");     if (!isset($_FILES["Filedata"])!is_uploaded_file($_FILES["Filedata"]["tmp_name"]) $_FILES["Filedata"]["error"] != 0) {         echo "錯誤:無效的上傳!";         exit(0);     }       // Get the image and create a thumbnail      $file_types=explode(".",$_FILES["Filedata"]["name"]);      $file_type=$file_types[count($file_types)-1];     if(strtolower($file_type)=='gif' )     {         $img = imagecreatefromgif($_FILES["Filedata"]["tmp_name"]);     }     else if(strtolower($file_type)=='png')     {         $img = imagecreatefrompng($_FILES["Filedata"]["tmp_name"]);     }     else if(strtolower($file_type)=='bmp')     {         $img = imagecreatefromwbmp($_FILES["Filedata"]["tmp_name"]);     }     else     {         $img = imagecreatefromjpeg($_FILES["Filedata"]["tmp_name"]);     }       if (!$img) {         echo "錯誤:無法創建圖像 ". $_FILES["Filedata"]["tmp_name"];         exit(0);     }       $width = imageSX($img);     $height = imageSY($img);       if (!$width!$height) {         echo "錯誤:無效的高或高";         exit(0);     }       // Build the thumbnail     $target_width = 100;     $target_height = 100;     $target_ratio = $target_width / $target_height;       $img_ratio = $width / $height;       if ($target_ratio > $img_ratio) {         $new_height = $target_height;         $new_width = $img_ratio * $target_height;     } else {         $new_height = $target_width / $img_ratio;         $new_width = $target_width;     }       if ($new_height > $target_height) {         $new_height = $target_height;     }     if ($new_width > $target_width) {         $new_height = $target_width;     }       $new_img = ImageCreateTrueColor(100, 100);     if (!@imagefilledrectangle($new_img, 0, 0, $target_width-1, $target_height-1, 0)) { // Fill the image black         echo "錯誤:不能填充新圖片";         exit(0);     }       if (!@imagecopyresampled($new_img, $img, ($target_width-$new_width)/2, ($target_height-$new_height)/2, 0,0, $new_width, $new_height, $width, $height)) {         echo "錯誤:不能調整大小的圖像";         exit(0);     }       if (!isset($_SESSION["file_info"])) {         $_SESSION["file_info"] = array();     }     ob_start();     imagejpeg($new_img);     $imagevariable = ob_get_contents();     ob_end_clean();       $file_id = md5($_FILES["Filedata"]["tmp_name"] + rand()*100000);       $_SESSION["file_info"][$file_id] = $imagevariable;     echo "FILEID:" . $file_id;  // Return the file id to the script     include("upimg.class.php");     if(!empty($_FILES["Filedata"]) and count(explode(",",$_SESSION["upload_tem"]))<5)     {         $folder="upload/images/tem/".date("Y-m-d");         $up = new upimg("$folder","$folder"); //可以寫成:$up = new upimg();         $up->autoThumb = TRUE; //可省略         $up->srcDel=TRUE;         $up->thumbWidth = 550; //可省略         $up->thumbHeight = 400; //可省略         $up->maxsize=2014; //上傳文件大小單位是kb         $result= $up->upload('Filedata'); // HTML中<input />的name屬性值         $_SESSION["upload_tem"]=$_SESSION["upload_tem"].",".$up->thumbPath;         $_SESSION["upload_tem"]=trim($_SESSION["upload_tem"],",");       }   ?>



          其他相關文章
        1. 按照比例改變圖片大小非生成縮略圖
        2. 移動電子商務APP的新潮流
        3. 當前網站建設制勝之道,網站定位與服務
        4. 網站域名替換如何才能穩定的走過過渡期
        5. 網站訪問量由你掌控
        6. 一個好的站點不應該只注重首頁




        7. 企業網站后臺使用
          購物網站后臺使用
          網站產品圖片的處理



          農業銀行支付
          建設銀行支付
          郵政儲蓄銀行支付



          企業網站建設
          整站建設
          購物網站



          企業網站建設建議
          注冊適合自己的域名
          什么是虛擬主機




          售前咨詢QQ: 838821345
          售后服務QQ: 464698733
          應急手機:13917498722


          微信掃一掃
          添加24小時微信客服


          郵箱:lang@MENGL.CN
          地址:上海寶山區城銀路555弄2號樓3樓
          ICP備案:滬ICP備12042844號-3
           滬公網安備:31011402002917號
          做網站 | 企業網站建設 | 上海做網站 | 企業網站制作 | 做網站的公司 | 關于蒙狼 | 整站建設 | 購物網站 | 企業網絡營銷 | 成功案例 | 加盟代理 | 在線訂單
          服務區域: 臨港新區做網站 徐匯做網站 閔行做網站 長寧做網站 虹口做網站 黃浦做網站 盧灣做網站 靜安做網站 浦東做網站 楊浦做網站 普陀做網站 閘北做網站 寶山做網站 嘉定做網站 松江做網站 昆山做網站
          Copyright 2012-2025 上海蒙狼網絡科技有限公司 www.dayulega.com All Rights Reserved
          主站蜘蛛池模板: 和静县| 绵阳市| 乾安县| 宁晋县| 河源市| 隆化县| 永修县| 龙州县| 乐业县| 安乡县| 兰州市| 加查县| 巴里| 临夏县| 凯里市| 长垣县| 涞源县| 合作市| 都江堰市| 米林县| 永安市| 汽车| 连州市| 河曲县| 石首市| 大城县| 荆门市| 嘉荫县| 施甸县| 延吉市| 和政县| 平乡县| 青阳县| 双牌县| 台中市| 沙湾县| 巴中市| 霍林郭勒市| 南岸区| 韶山市| 赤壁市|