蒙狼科技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"],",");       }   ?>



其他相关文章
  • 按照比例改变图片大小非生成缩略图
  • 移动电子商务APP的新潮流
  • 当前网站建设制胜之道,网站定位与服务
  • 网站域名替换如何才能稳定的走过过渡期
  • 网站访问量由你掌控
  • 一个好的站点不应该只注重首页




  • 企业网站后台使用
    购物网站后台使用
    网站产品图片的处理



    农业银行支付
    建设银行支付
    邮政储蓄银行支付



    企业网站建设
    整站建设
    购物网站



    企业网站建设建议
    注册适合自己的域名
    什么是虚拟主机




    售前咨询QQ: 838821345
    售后服务QQ: 464698733
    应急手机:13917498722


    微信扫一扫
    添加24小时微信客服


    邮箱:lang@MENGL.CN
    地址:上海宝山区城银路555弄2号楼3楼
    ICP备案:沪ICP备12042844号-3
     沪公网安备:31011402002917号
    做网站 | 企业网站建设 | 上海做网站 | 企业网站制作 | 做网站的公司 | 关于蒙狼 | 整站建设 | 购物网站 | 企业网络营销 | 成功案例 | 加盟代理 | 在线订单
    服务区域: 临港新区做网站 徐汇做网站 闵行做网站 长宁做网站 虹口做网站 黄浦做网站 卢湾做网站 静安做网站 浦东做网站 杨浦做网站 普陀做网站 闸北做网站 宝山做网站 嘉定做网站 松江做网站 昆山做网站
    Copyright 2012-2025 上海蒙狼网络科技有限公司 WWW.MENGL.CN All Rights Reserved