茄子在线看片免费人成视频,午夜福利精品a在线观看,国产高清自产拍在线观看,久久综合久久狠狠综合

    <s id="ddbnn"></s>
  • <sub id="ddbnn"><ol id="ddbnn"></ol></sub>

  • <legend id="ddbnn"></legend><s id="ddbnn"></s>

    php文件上傳類完整實例
    來源:易賢網(wǎng) 閱讀:959 次 日期:2016-08-23 14:57:48
    溫馨提示:易賢網(wǎng)小編為您整理了“php文件上傳類完整實例”,方便廣大網(wǎng)友查閱!

    本文實例講述了php文件上傳類。分享給大家供大家參考,具體如下:

    /**

    $file=new class_file($file_array,"flash/");

     $file->set_allow_type(array("jpg","jpeg","gif"));

     $file->is_limit_size();

     if(!$file->allow_file_size()){

       echo $file->error;

       exit;

     }

     if(!$file->allow_file_type()){

        echo $file->error;

        exit();

      }else if(!$file->uploadfile()){

      echo $file->error;

      exit;

     }

    **/

    <?php

     class class_file{

       private $file_type;

       private $file_size;

       private $save_path;

       private $file_path;

       private $allow_type=array();

       private $allow_size;

       private $file_name;

       private $flag=false;

       private $mime_type;

       private $is_limit_size=false;

       public $error;

       //構(gòu)造函數(shù)

      function class_file($file_array,$save_path){

           $this->file_path=$file_array['tmp_name'];

           $this->file_size=$file_array['size'];

           $this->file_type=$file_array['type'];

           $this->save_path=$save_path;

        }

        //設(shè)置允許的文件類型

       function set_allow_type($allow_type){

          $this->allow_type=$allow_type;

        }

        //設(shè)置允許的文件大小

       function set_allow_size($allow_size){

          $this->allow_size=$allow_size;

        }

        //文件上傳

       public function uploadfile(){

         if(!$this->allow_file_type()){

         $this->file_name();

         }

         if(move_uploaded_file($this->file_path,$this->save_path.$this->file_name)){

           return true;

         }else{

           $this->error="文件上傳失敗";

           return;

         }

       }

    //判斷文件上傳的類型

       function allow_file_type(){

         $this->file_name();

         if(in_array($this->mime_type,$this->allow_type)){

             return true;

           }else{

             $this->error="不允許上傳的類型";

             exit();

           }

       }

     //判斷文件上傳的大小

       function allow_file_size($size=100){

         if($this->is_limit_size){

         $this->set_allow_size($size);

         if($this->allow_size>=$this->file_size){

           return true;

         }else{

           $this->error="超過文件上傳大小限制";

         }

         }

       }

     //是否限制文件大小

       function is_limit_size(){

         $this->is_limit_size=true;

       }

    //文件類型和文件名稱

       function file_name(){

        $this->mime_type=substr($this->file_type,strpos($this->file_type,"/")+1);

       if($this->mime_type=="pjpeg"){

         $this->mime_type="jpg";

        }

       if($this->mime_type=="x-ms-wma"){

          $this->mime_type="wma";

        }

        if($this->mime_type=="x-ms-wmv"){

          $this->mime_type="wmv";

        }

        $this->file_name=date("YmdHis").".$this->mime_type";

       }

       function _get_file_name(){

         return $this->file_name;

       }

     }

    ?>

    希望本文所述對大家PHP程序設(shè)計有所幫助。

    更多信息請查看網(wǎng)絡(luò)編程
    易賢網(wǎng)手機網(wǎng)站地址:php文件上傳類完整實例
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

    2026國考·省考課程試聽報名

    • 報班類型
    • 姓名
    • 手機號
    • 驗證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
    工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
    云南網(wǎng)警備案專用圖標(biāo)
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
    云南網(wǎng)警報警專用圖標(biāo)