PHP教程之多文件上傳類_PHP教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
推薦:PHP Token(令牌)設(shè)計PHP Token(令牌)設(shè)計 設(shè)計目標(biāo): 避免重復(fù)提交數(shù)據(jù). 檢查來路,是否是外部提交 匹配要執(zhí)行的動作(如果有多個邏輯在同一個頁面實(shí)現(xiàn),比如新增,刪除,修改放到一個PHP文件里操作) 這里所說的token是在頁面顯示的時候,寫到FORM的一個隱藏表單項(type=hidden). token
PHP多文件上傳類/*
多文件上傳類
修改:Linvo 2008-2-15
*/
class more_file_upload{
const FILE_PATH='../upfileclass/uploadfile/';
var file_type;
var file_type_array;
var file_type_real_array;
var file_type_string;
var file_name;
var file_size;
var file_tmp_name;
var file_error;
var handledate;
static totalsize=0;
function __construct(file_name,file_error,file_size,file_tmp_name,file_type){
this->handledate=date('m-d-Y');
if (!empty(file_name)){
this->file_name = file_name;
this->file_error = file_error;
this->file_size = file_size;
this->file_tmp_name = file_tmp_name;
this->file_type = file_type;
this->file_type_array = array('/', 'image/gif', 'image/jpg', 'image/jpeg', 'image/pjpeg', 'image/png');
this->file_type_real_array = array(0.1, 'jpg'=>74707370, 'gif'=>7173, 'bmp'=>6677, 'png'=>807871);
this->show_execute_message(this->file_error,this->file_name,this->file_type,this->file_size);
}
}
function __destruct(){
this->file_name = NULL;
this->file_error = NULL;
this->file_size = NULL;
this->file_tmp_name = NULL;
this->file_type = NULL;
self::totalsize = 0;
}
function show_execute_message(smfileerror,smfilename,smfiletype,smfilesize){
if(smfileerror>0){
switch (smfileerror){
case 1: smfilemessage='<strong>文件超過服務(wù)器的約定大小!</strong>';break;
case 2: smfilemessage='<strong>文件超過指定的文件大!</strong>';break;
case 3: smfilemessage='<strong>文件只上傳了部分!</strong>';break;
case 4: echo "this->file_name ".'文件上傳失!<br/>';break;
}
self::__destruct();
}else{
smfiletypeflag = array_search(smfiletype,this->file_type_array);
分享:如何用php過濾危險html代碼用PHP過濾html里可能被利用來引入外部危險內(nèi)容的代碼。有些時候,需要讓用戶提交html內(nèi)容,以便豐富用戶發(fā)布的信息,當(dāng)然,有些可能造成顯示頁面布局混亂的代碼也在過濾范圍內(nèi)。 #用戶發(fā)布的html,過濾危險代碼 function uh(str) { farr = array( /\s+/, //
相關(guān)PHP教程:
- PHPNOW安裝Memcached擴(kuò)展方法詳解
- php記錄頁面代碼執(zhí)行時間
- PHP中獎概率的抽獎算法程序代碼
- apache設(shè)置靜態(tài)文件緩存方法介紹
- php對圖像的各種處理函數(shù)代碼小結(jié)
- PHP 關(guān)于訪問控制的和運(yùn)算符優(yōu)先級介紹
- 關(guān)于PHP語言構(gòu)造器介紹
- php/js獲取客戶端mac地址的實(shí)現(xiàn)代碼
- php5.5新數(shù)組函數(shù)array_column使用
- PHP preg_match的匹配多國語言的技巧
- php 中序列化和json使用介紹
- php采集文章中的圖片獲取替換到本地
- 相關(guān)鏈接:
- 教程說明:
PHP教程-PHP教程之多文件上傳類。