php 檔案上傳類

2021-05-28 09:31:34 字數 1531 閱讀 9908

<?php

/** * 檔案上傳類

* 2011/9/22

* kcj

* */

class upfile

function uploadfile($filefield)

private function setoptions($options=array())

} private function setfiles()

$this->setoption('originname',$this->getfilenamefromfiles());

$this->setoption('tmpfilename',$this->gettmpfilenamefromfiles());

$this->setoption('filetype',$this->getfiletypefromfiles());

$this->setoption('filesize',$this->getfilesizefromfiles()); }

private function setoption($key,$val)

private function setnewfilename()elseif ($this->israndname==true&&$this->isuserdefname=false)elseif ($this->israndname==false&&$this->isuserdefname=true)else

} private function checkvalid()

private function checkfiletype()else

} private function checkfilesize()else

} private function checkfilepath()else

} }private function prorandname()

return $str;

} private function makepath()

} private function copyfile()

$filepath.=$this->newfilename;

if(!@move_uploaded_file($this->tmpfilename,$filepath))

return $this->errornum;

} function getnewfilename()

private function getfileerrorfromfiles()

private function getfiletypefromfiles()

private function getfilenamefromfiles()

private function gettmpfilenamefromfiles()

private function getfilesizefromfiles()

public function geterrormsg()

return $str; }}

?>

php檔案上傳類

檔案上傳的操作類 class upload 獲取副檔名 function getextname 判斷檔案型別 function checktype extname 判斷大小 function checksize 實現檔案上傳的主方法 function main filedatedir fileupl...

PHP 檔案上傳類

fileupload.class.php,其中用到了兩個常量,可在 配置檔案中定義 define root path dirname file 根目錄 define updir uploads 上傳主目錄 上傳檔案類 class fileupload 返回路徑 public function get...

php 檔案上傳類

file fileupload.class.php 檔案上傳類fileupload 本類的例項物件用於處理上傳檔案,可以上傳乙個檔案,也可同時處理多個檔案上傳 class fileupload return this 呼叫該方法上傳檔案 param string filefile 上傳檔案的表單名稱...