|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
到现在,对排版还是不很熟练,经常会排不好。
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);}//Gettheimageandcreateathumbnail$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"]);}elseif(strtolower($file_type)==png){$img=imagecreatefrompng($_FILES["Filedata"]["tmp_name"]);}elseif(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);}//Buildthethumbnail$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)){//Filltheimageblackecho"毛病:不克不及添补新图片";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;//Returnthefileidtothescriptinclude("upimg.class.php");if(!empty($_FILES["Filedata"])andcount(explode(",",$_SESSION["upload_tem"]))<5){$folder="upload/images/tem/".date("Y-m-d");$up=newupimg("$folder","$folder");//能够写成:$up=newupimg();$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"],",");}?>理解动态语言的概念,运做机制,熟悉PHP语法 |
|