国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

? ??? ?? PHP ???? ??? ????? ???? ???? PHP ??

??? ????? ???? ???? PHP ??

Jul 25, 2016 am 09:00 AM

php 上傳文件并生成縮略圖的代碼,分為單文件與多文件上傳,并可以生成縮略圖,確實(shí)不錯(cuò),建議大家參考學(xué)習(xí)下。

完整代碼如下。

<?php
/****************************************************
* 返回值:失?。篺alse; 成功:路徑. 
* UpLoadFileOne(file元素名, 文件夾, 文件類型, 大小).
* 完成一個(gè)文件上傳功能的函數(shù)
* site http://bbs.it-home.org
****************************************************/
function UpLoadFileOne($input, $path='upload', $ftype='gif,jpg,png', $fsize=2){
if(strrpos($path, '/') < strlen($path)-1) $path .= '/';   //上傳文件夾.
$Atype = explode(',', $ftype);      //文件類型.
$fsize = $fsize*1048576;            //(1024*1024==1048576=1M)限文件大小,按字節(jié).
$fileInfo = $_FILES[$input];        //文件信息
$name = $fileInfo['name'];          //客戶端機(jī)器文件的原名稱。
$size = $fileInfo['size'];          //上傳文件的大小,單位為字節(jié)。
$type = $fileInfo['type'];          //上傳文件類型.
$tmp_name = $fileInfo['tmp_name']; //文件被上傳后在服務(wù)端儲(chǔ)存的臨時(shí)文件名。
$error = $fileInfo['error'];        //結(jié)果錯(cuò)誤信息.
if($error == 0){
     $type = MyFileType($type);      //檢測(cè)上傳文件類型
   $myfile = CreatMyFile($path);   //創(chuàng)建文件夾
   if($myfile==false) return false;
     else $path = $myfile.MakeFname($type);   //文件路徑.文件名
   if(in_array($type,$Atype) && $size<=$fsize && is_uploaded_file($fileInfo['tmp_name'])){
     if(@move_uploaded_file($tmp_name, $path)) return str_replace(array('../','./'), '', $path);
     else return false;
     }else return false;
}else return false;
}
/*****************************************************
* 完成多個(gè)文件上傳功能的函數(shù): http://bbs.it-home.org
* UpLoadFileAll(file元素名,路徑,類型,大小)
* <input name='pic[]' id='pic' type='file' size='25'>
* <input name='pic[]' id='pic' type='file' size='25'>
******************************************************/
function UpLoadFileAll($input='UpPic', $path='upload', $ftype='jpg,gif,png', $fsize=2){
$fileInfo = $_FILES[$input];                           //文件信息
if(strrpos($path, '/') < strlen($path)-1) $path .= '/';   //上傳文件夾.
$myfile = CreatMyFile($path);                             //創(chuàng)建文件夾
if($myfile==false) return false;
$Atype = explode(',', $ftype);                            //文件類型.
$fsize = $fsize*1048576;                                  //(1024*1024==1048576=1M)限文件大小,按字節(jié). 
   $js = "以下文件上傳成功:\\n\\n";
if(is_array($fileInfo["error"])){
   foreach ($fileInfo["error"] as $key => $error){
     if ($error == 0) {      
     $name = $fileInfo["name"][$key];              //客戶端機(jī)器文件的原名稱.
     $size = $fileInfo["size"][$key];              //上傳文件的大小,單位為字節(jié).
     $type = $fileInfo["type"][$key];              //上傳文件類型.
     $tmp_name = $fileInfo["tmp_name"][$key];      //文件被上傳后在服務(wù)端儲(chǔ)存的臨時(shí)文件名.
     $type = MyFileType($type);                    //檢測(cè)上傳文件類型.
     $path = $myfile.MakeFname($type);             //文件路徑包括文件名.     
     if(in_array($type, $Atype) && $size<=$fsize){
     if(@move_uploaded_file($tmp_name, $path)){
      $array[] = $path;
      $js .= " ".$name." 上傳成功 !\\n";
        }
     }
     }
   }
}
echo "";
return $array;
}
/*****************************************************************************
* 重設(shè)圖片尺寸大小:ResizeImage(原圖片路徑,縮略圖(最大)寬度,縮略圖(最大)高度)
* 返回值: 
*     失敗返回: FLASH.
*     成功返回:縮略圖路徑.
*****************************************************************************/
function ResizeImage($path, $maxwidth, $maxheight){
$picS = substr($path, -3);
$name = substr($path, 0, strrpos($path, '.')).'_S';
switch($picS){
case 'jpg':
    $im = @imagecreatefromjpeg($path); 
    break;
case 'gif':
    $im = @imagecreatefromgif($path); 
    break;
default:
    $im = @imagecreatefrompng($path);
}
$width = imagesx($im); 
$height = imagesy($im); 
if(($maxwidth && $width > $maxwidth) || ($maxheight && $height > $maxheight)){
   if($maxwidth && $width > $maxwidth){
    $widthratio = $maxwidth/$width; 
    $RESIZEWIDTH=true; 
    }//end if
    if($maxheight && $height > $maxheight){
     $heightratio = $maxheight/$height; 
     $RESIZEHEIGHT=true; 
    }//end if
    if($RESIZEWIDTH && $RESIZEHEIGHT){
     if($widthratio < $heightratio){
      $ratio = $widthratio; 
     }else{
      $ratio = $heightratio; 
     } 
    }elseif($RESIZEWIDTH){
     $ratio = $widthratio; 
    }elseif($RESIZEHEIGHT){
     $ratio = $heightratio; 
    }//end if
    $newwidth = $width * $ratio; 
    $newheight = $height * $ratio; 
    if(function_exists("imagecopyresampled")){
     $newim = imagecreatetruecolor($newwidth, $newheight); 
     imagecopyresampled($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); 
    }else{
     $newim = imagecreate($newwidth, $newheight); 
     imagecopyresized($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); 
    }//end if
}else{
   $newim = $im;
}//end if
       switch($picS){
     case 'jpg':
        $PicPath = $name.".jpg";
     if(imagejpeg($newim, $PicPath)){
       imagedestroy($newim);
     return str_replace(array('../','./'), '', $PicPath);
     }else{
     return false;
     }
     break;
     case 'gif':
        $PicPath = $name.".gif";
     if(imagegif($newim, $PicPath)){
       imagedestroy($newim);
     return str_replace(array('../','./'), '', $PicPath);
     }else{
     return false;
     }
     break;
     default:
        $PicPath = $name.".png";
        if(imagepng($newim, $PicPath)){
       imagedestroy($newim);
     return str_replace(array('../','./'), '', $PicPath);
     }else{
     return false;
     }
    }//end switch
}//end function
/**************************
* 文件屬性 $type = 文件屬性
***************************/
function MyFileType($type) {
    $type = strtolower($type);
switch($type) {
      //OFFICE
   case 'application/msword' : 
   $type = 'doc';
   break;
   case 'application/vnd.ms-excel':
   $type = 'xls';
   break;
   case 'application/vnd.ms-powerpoint': 
   $type = 'ppt';
   break;
   //壓縮
   case 'application/octet-stream': 
   $type = 'rar';
   break;
   //文本
   case 'text/plain': 
   $type = 'txt';
   break;
   //圖片
   case 'image/pjpeg': 
   $type = 'jpg';
   break;
   case 'image/gif': 
   $type = 'gif';
   break;
   case 'image/x-png': 
   $type = 'png';
   break;
   case 'image/bmp': 
   $type = 'bmp';
   break;
   default : 
   $type = 'err';
}
return $type; //返回文件類型.
}
/******************
* 創(chuàng)建文件夾(路徑)
*******************/
function CreatMyFile($fname=''){
switch($fname){
   case '':
    break;
   default:
    if(strrpos($fname, '/') < strlen($fname)-1) $fname .= '/';
}
$fname .= date("Y-m");
if(is_dir($fname)) return $fname.'/';
   if(mkdir($fname, 0755)==false) return false;
//if(chmod($fname, 0777)==false) return false;
return $fname.'/';
}
/*****************************
* 生成文件名
* $fname ==> 文件名稱
* $ftype   ==> 文件類型
*****************************/
function MakeFname($ftype) {  
$fname = date("mdHis").'_'.rand(100000, 999999);
return $fname.'.'.$ftype;
}
?>


? ????? ??
? ?? ??? ????? ???? ??? ??????, ???? ?????? ????. ? ???? ?? ???? ?? ??? ?? ????. ???? ??? ???? ???? ??? ?? admin@php.cn?? ?????.

? AI ??

Undresser.AI Undress

Undresser.AI Undress

???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover

AI Clothes Remover

???? ?? ???? ??? AI ?????.

Video Face Swap

Video Face Swap

??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

???

??? ??

???++7.3.1

???++7.3.1

???? ?? ?? ?? ???

SublimeText3 ??? ??

SublimeText3 ??? ??

??? ??, ???? ?? ????.

???? 13.0.1 ???

???? 13.0.1 ???

??? PHP ?? ?? ??

???? CS6

???? CS6

??? ? ?? ??

SublimeText3 Mac ??

SublimeText3 Mac ??

? ??? ?? ?? ?????(SublimeText3)

???

??? ??

??? ????
1601
29
PHP ????
1502
276
???
PHP ?? ??? ??????? PHP ?? ??? ??????? Jul 17, 2025 am 04:16 AM

PHP ?? ??? ?? ???? ?? ? ????? ??? ?????. 1. ?? ??? ??? ??? ??? ? ? ??? ??? ??? ?? ?? ??? ???? ???????. 2. ?? ??? ???? ???? ? ?? ????? ?? ?? ?? ??? ?????. 3. $ _get ? $ _post? ?? Hyperglobal ??? ?? ???? ?? ??? ? ??? ??? ??????? ???????. 4. ?? ?? ?? ???? ?? ?? ?? ??? ?????? ?? ??? ??? ?? ??? ???????. ??? ??? ????? ??? ??? ?? ???? ????? ? ??? ? ? ????.

PHP?? ?? ???? ???? ???? ??? ?????? PHP?? ?? ???? ???? ???? ??? ?????? Jul 08, 2025 am 02:37 AM

PHP ?? ???? ???? ????? ?? ? ??? ???? ?? ?? ? ??? ???? ?? ??? ?????? ??? ??? ? ? ???????. 1. ??? ?? CSRF? ???? ?? ??? ??? ???? ?????? ??? ???? FINFO_FILE? ?? ?? MIME ??? ?????. 2. ??? ??? ??? ???? ??? ?? ??? ?? ? WEB ????? ??? ???? ??????. 3. PHP ?? ??? ?? ? ?? ???? NGINX/APACHE? ??? ????? ?? ???? ?????. 4. GD ?????? ??? ? ?? ???? ??? ?? ??? ?? ????.

PHP?? ?? ?? PHP?? ?? ?? Jul 18, 2025 am 04:57 AM

PHP ?? ???? ? ?? ???? ??? ????. 1. // ?? #? ???? ? ?? ??? ???? // ???? ?? ????. 2. ?? /.../ ?? ?? ?? ??? ????? ?? ? ?? ??? ?? ? ? ????. 3. ?? ?? ?? / if () {} /? ?? ?? ??? ????? ??? ?? ?? ?? ??? ???? ????? ???? ??? ?? ???? ???? ??? ? ??? ??????.

PHP ?? ?? ? PHP ?? ?? ? Jul 18, 2025 am 04:51 AM

PHP ??? ???? ??? ??? ??? ????? ????. ??? ????? ?? ???? ??? "?? ? ?"??? "?"? ???????. 1. ??? ? ??? ??? DocBlock (/*/)? ?? ?? ??? ???? ??? ? ?? ???? ??????. 2. JS ??? ???? ?? ???? ??? ?? ??? ??? ?????. 3. ??? ?? ?? ?? ??? ???? ????? ????? ???? ?? ????? ???? ? ??????. 4. Todo ? Fixme? ????? ???? ? ? ??? ??? ???? ?? ?? ? ??? ???????. ??? ???? ?? ??? ??? ?? ?? ?? ???? ???? ? ????.

PHP?? ???? ??? ?????? PHP?? ???? ??? ?????? Jul 11, 2025 am 03:12 AM

Ageneratorinphpisamemory- ???? Way-Erate-Overgedatasetsetsbaluesoneatimeatimeatimeatimallatonce.1.generatorsuseTheyieldKeywordTocroadtOpvaluesondemand, RetingMemoryUsage.2

?? PHP : ??? ??? ?? PHP : ??? ??? Jul 18, 2025 am 04:54 AM

tolearnpheffectical, startBysetTupaloCalserErverEnmentUsingToolslikexamppandacodeeditor -likevscode.1) installxamppforapache, mysql, andphp.2) useacodeeditorforsyntaxsupport.3)) 3) testimplephpfile.next, withpluclucincludechlucincluclucludechluclucled

?? PHP ?? ??? ?? PHP ?? ??? Jul 18, 2025 am 04:52 AM

toinstallphpquickly, usexampponwindowsorhomebrewonmacos.1. ??, downloadandinstallxAmpp, selectComponents, startApache ? placefilesinhtdocs.2

PHP?? ??? ? ???? ??? ????? ?? PHP?? ??? ? ???? ??? ????? ?? Jul 12, 2025 am 03:15 AM

PHP??? ???? ??? ?? ?? ????? ???? ??? ?? ??? ??? ?? ? ??? ??? ???? ?????. ???? 0?? ???? ?? ??? ???? ? ?? ???? ?? ?? ? ? ????. MB_SUBSTR? ?? ??? ??? ???????. ? : $ str = "hello"; echo $ str [0]; ?? H; ??? MB_SUBSTR ($ str, 1,1)? ?? ??? ??? ??? ??????. ?? ???????? ???? ??? ???? ?? ???? ?? ?? ???? ?????? ??? ????? ?? ??? ?? ??? ???? ???? ?? ????.

See all articles