PHP中的乙個很好用的檔案上傳類

2021-12-29 20:14:20 字數 1670 閱讀 3451

<?php

class fileupload

else

}}  //定義不同的錯誤級別

private function geterror()時出錯:";

switch($this->errornum)個位元組";

break;

case -3:

$str.="上傳失敗";

break;

case -4:

$str.="建立存放上傳目錄失敗,請重新指定上傳目錄";

break;

case -5:

$str.="必須指定上傳檔案的路徑";

break;

default:

$str.="未知的錯誤";

return $str."

";  }

//為成員屬性賦值的函式

private function setoption($key,$val)

//用於檢查上傳檔案的路徑

private function checkfilepath()

//判斷路徑是否存在並且是否可寫

if(!file_exists($this->filepath)||!is_writable($this->filepath))

}return true;

}  //檢查檔案大小的函式

private function checkfilesize()

else

}  //檢查上傳檔案的型別

private function checkfiletype()

else

}//上傳乙個檔案

function uploadfile($filefield)

else

}else

}else

//檢查檔案的路徑是否存在錯誤

if(!$this->checkfilepath())

if(!$return)

return $return;

}  //設定和$_files有關的內容

private function setfiles($name="",$tmp_name="",$size=0,$error=0)

$arrstr=explode(".",$name);

$this->setoption("filetype",strtolower($arrstr[count($arrstr)-1]));

$this->setoption("originname",$name);

$this->setoption("tmpfilename",$tmp_name);

$this->setoption("filesize",$size);

return true;

}  //用於獲取上傳檔案後檔案的名稱

function getnewfilename()

//上傳檔案失敗時,顯示錯誤資訊的函式

function geterrormsg()

private function prorandname()

//設定上傳後的檔名稱

private function setnewfilename()

else

}//拷貝檔案

private function copyfile()

else

}}   }

PHP中的乙個很好用的檔案上傳類

class fileupload else 定義不同的錯誤級別 private function geterror 時出錯 switch this errornum 個位元組 break case 3 str.上傳失敗 break case 4 str.建立存放上傳目錄失敗,請重新指定上傳目錄 br...

WTL 乙個很好用的ToolTip

找到了乙個老外寫的很好用的tooltip,但是有兩個小問題,終於解決了,拿出來和大家分享下。問題1 有時候出現這樣的情況,滑鼠劃上去後立馬彈出提示,然後消失,最後又彈出一次 問題2 提示框彈出後預設只顯示5秒鐘就消失了,這樣時間太短了,提示的內容還沒看完就消失了。解決方法 問題1 m tt.setd...

乙個很好用的歸併排序

第一天學麻省理工的演算法導論,寫出了那個歸併排序,自己給它新增了好多功能,你只要輸入要測試多少組資料,他便會自動生成並將輸入寫入in.txt中,即使沒有它也會自動建立,輸出也一樣 include include include include int len 0 using namespace st...