class Upload { var $fileDir = "./tmp/"; // 檔案上傳後放置的目錄 // --------------------------------------------------------------------------- var $tmpFile = ""; // 上傳的系統暫存檔名稱 var $fileName= ""; // 檔名 var $fileType= ""; // 檔案格式 var $fileSize= ""; // 檔案大小 var $name = ""; // 檔名(不含副檔名) var $extName = ""; // 副檔名 // --------------------------------------------------------------------------- var $sizeLimit = ""; // 檔案大小限制 var $typeLimit = ""; // 檔案型態限制 var $widthLimit = ""; // 圖檔寬度限制 var $heightLimit= ""; // 讀檔高度限制 var $err = ""; // 錯誤訊息 function info() { $classname = "Upload"; $ary = get_class_methods($classname); echo "
"; echo "Class $classname method:" . sizeof($ary) . "\n"; for ($i=0; $i"; } //取得資訊 function getinfo($fdname) { global $HTTP_POST_FILES; $this->tmpFile = $HTTP_POST_FILES[$fdname]['tmp_name']; $this->fileName = $HTTP_POST_FILES[$fdname]['name']; $this->fileType = $HTTP_POST_FILES[$fdname]['type']; $this->fileSize = $HTTP_POST_FILES[$fdname]['size']; $tmp = explode(".", $this->fileName); $this->name = $tmp[0]; $this->extName = $tmp[1]; } //儲存 function save($fn="") { $this->limit(); if ($this->err) { //Nothing to do } else { $rst = @copy($this->tmpFile, $this->fileDir . $this->name . "." . $this->extName); } return $rst; } //限制 function limit() { //檔案容量 if ($this->sizeLimit && ($this->fileSize > $this->sizeLimit)) { $this->err .= "檔案超過" . $this->sizeLimit . "Byte 容量限制\n"; } //檔案類型 if ($this->typeLimit) { $tmp = explode("|", $this->typeLimit); for ($i=0;$iClass $classname properties:" . sizeof($ary) . "\n"; for (reset($ary); $key=key($ary); next($ary)) { echo "$key : $ary[$key]" . "\n"; } echo "