在php中使用jquery uploadify进行多图片上传

时间:2016.04.21 发布人:鍩庡崡缃戜簨

在php中使用jquery uploadify进行多图片上传

已解决问题

谷歌鍩庡崡缃戜簨用户在2016.04.21提交了关于“西班牙紧急在php中使用jquery uploadify进行多图片上传”的提问,欢迎大家涌跃发表自己的观点。目前共有1个回答,最后更新于2025-02-23T02:55:50。希望大家能够帮助她。

详细问题描述及疑问:期待您的答案,感谢你,我会记得你对我的好的 !

希望以下的回答,能够帮助你。

第1个回答

用户名:fanqieteng  

  jqueryuploadify是一款Ajax风格的批量图片上传插件,在Ph**P中使用jqueryuploadify很方便,请按照本问答文介绍的方法和步骤,为你的Ph**P程序增加jqueryuploadify插件的批量上传图片功能。

  本文是以次触盾球犯dilicms为基础,为其增加图片上传功能。

  1.增加**表dili_fieldtypes新字段:k=>image,V=>图片上传区域(政之单屋费激城VACh**AR);

  2.修改application/libraries/dili/Field_beh**ior.php,在switch中增加如下代码:

  1case'i故错力怀然孔mage':

  2$fiel背非殖存d=array(

  3'type'=>'角被钢决百万策委VARCh**AR',

  诉区受板失介前斤稳用另4'constraint'=>255,

  5'default'=>''

  6);

  7bre**;

  3.弱省表审兵按修改application/libraries/dili/Form.php并且增加如下代码:

  1function_image($fileld,$default){

 单权 2//$type='type=hidden';

  3//$width=($field['width']?$field['width']:'57评送势苗够从字0').'px;';

  4//$height=($field['height']?$field['height']:'415').'px;';

  5return;

  6}

  4.在content_form.php和category_content_form.php中增加判断代码:

  01

  02if($v['type']=="image"):

  03?>

  04

  05

  06

  07上传

  含括句真黑善屋华补08取消上传

  09

  10"value=""/>

  11"value=""/>

  12asset/js/uploadify/uploadi盾许移矿现起律波态息十fy.css"type="te硫哥风洋秋观女xt/css"rel="stylesheet"/>

  13

  14

取都宽秋粉希该点弦主心  42

  6.诉新建photo.php文件:

  01

  02if(!defined('BA**PATh**'))exit('Nodirectscriptaccessallowed');

  03date_default_timezone_set('Asia/Shanghai');

  04classPhotoextendsFront矛拿抓哥志_Controller{

  05publi每卷象沙岩养始效试飞cfunction__construct()

  06{

  07parent::__construct();

  08}

  09function_getFilePath()

  10{

  11$path="att况广甲汉飞海斗achments/".date("Y")."/";

  12if(!file_exists($path)){

  13mkdir($path,'777');

  14}

  15$path.=date("m")."/";

  16if(!file_exists($path)){

  17mkdir($path,'777');

  18}

  19return$path;

  20}

  21function_creat_photothumbs($FileName,$setW){

  22$IMGInfo=getimagesize($FileName);

  23if(!$IMGInfo)returnfalse;

  24if($IMGInfo['mime']=="image/pjpeg"||$IMGInfo['mime']=="image/jpeg"){

  25$ThisPhoto=imagecreatefromjpeg($FileName);

  26}elseif($IMGInfo['mime']=="image/x-png"||$IMGInfo['mime']=="image/png"){

  27$ThisPhoto=imagecreatefrompng($FileName);

  28}elseif($IMGInfo['mime']=="image/gif"){

  29$ThisPhoto=imagecreatefromgif($FileName);

  30}

  31$width=$IMGInfo['0'];

  32$height=$IMGInfo['1'];

  33$scale=$height/$width;

  34$nw=$setW;

  35$nh=$nw*$scale;

  36$NewPhoto=imagecreatetruecolor($nw,$nh);

  37imagecopyresampled($NewPhoto,$ThisPhoto,0,0,0,0,$nw,$nh,$width,$height);

  38ImageJpeg($NewPhoto,$FileName);

  39returntrue;

  40}

  41function_s**ephoto_post(){

  42$dest_dir=$this->_getFilePath();

  43if(!empty($_FILES)){

  44$date=date('Ymd');

  45//$dest_dir=$this->_getFilePath();

  46$photoname=$_FILES["Filedata"]['name'];

  47$phototype=$_FILES['Filedata']['type'];

  48$photosize=$_FILES['Filedata']['size'];

  49$fileInfo=pathinfo($photoname);

  50$extension=$fileInfo['extension'];

  51$newphotoname=date("Ymdh**is").mt_rand(10000,99999).'.'.$extension;

  52$dest=$dest_dir.$newphotoname;

  53//move_uploaded_file($_FILES['Filedata']['tmp_name'],iconv("UTF-8","gb2312",$dest));

  54move_uploaded_file($_FILES['Filedata']['tmp_name'],$dest);

  55//chmod($dest,0755);

  56//如果宽度大于600则要进行裁剪

  57$arr=getimagesize($dest);

  58if($arr[0]>600){

  59$thumb_w=600;

  60$this->_creat_photothumbs($dest,$thumb_w);

  61}

  62//生成缩略图

  63$config2['image_library']='gd2';

  64$config2['source_image']=$dest;

  65$config2['create_thumb']=TRUE;

  66$config2['maintain_ratio']=TRUE;

  67$config2['width']=170;

  68$config2['height']=150;

  69$config2['master_dim']="width";

  70$config2['thumb_marker']="_1";

  71$this->load->library('image_lib',$config2);

  72$this->image_lib->resize();

  73echo$dest;

  74}

  75}

  76}

  77?>

  好了,可以测试了。