php檔案上傳類(該類支援單個或者多個檔案上傳)(1/2)_PHP教程

來源:互聯網
上載者:User
php檔案上傳類(該類支援單個或者多個檔案上傳) /** * 類名:upfile * 作用:處理檔案上傳 * 說明,該類處理單個或者多個檔案上傳,使用該類時,只需要實列化該類 * 例:

/php教程檔案上傳類(該類支援單個或者多個檔案上傳)




無標題文檔


//php檔案上傳類(該類支援單個或者多個檔案上傳)
/**
* 類名:upfile
* 作用:處理檔案上傳
* 說明,該類處理單個或者多個檔案上傳,使用該類時,只需要實列化該類
* 例:
* $up = upfile()
* $up->update_file($_file['filename'])
*
* $up->update_file 函數返回一個數組,如果是多檔案上傳,則為多維資料。
* 數組的內容:
* $fileinfo['file_size'] 上傳檔案的大小
* $fileinfo['file_suffix'] 上傳檔案的類型
* $fileinfo['file_name'] 上傳檔案的名字
* $fileinfo['error'] 上傳檔案產生的錯誤
*

*/
class upfile {
public $fcount = 1; //上傳檔案的數量
public $ftype = array('jpg','jpeg','gif','png'); //檔案格式
public $fsize = 1024; //檔案大小單位kb
public $fdir = 'www.bkjia.com/'; //檔案存放目錄
public $errormsg = ''; //產生的臨時錯誤資訊

/**
*函數名:get_tmp_file($putfile)
*作用:取得上傳的臨時檔案名稱
*@param array $putfile
*@return string $upimg 返回臨時檔案名稱
*/
function get_tmp_file($putfile){
if($this->fcount == 1){
$tmpfile = $putfile['tmp_name'];
}else{
for($i=0;$i<$this->fcount;$i++){
$tmpfile[] = $putfile['tmp_name'][$i];
}
}
return $tmpfile;
}1 2

http://www.bkjia.com/PHPjc/444891.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/444891.htmlTechArticlephp檔案上傳類(該類支援單個或者多個檔案上傳) /** * 類名:upfile * 作用:處理檔案上傳 * 說明,該類處理單個或者多個檔案上傳,使用該類時,...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.