第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

我又又又報(bào)錯(cuò)了...

<?php?


/**

?* param string $fileName

?* param string $maxSize

?* param string uploadPath

?* param array $allowMime

?* param array $endExt

?* param array $fileInfo

?*/

//面向?qū)ο髮懸粋€(gè)文件上傳

class upload{

protected $fileName;

protected $maxSize;

protected $endExt;

protected $uploadPath;

protected $flage;

protected $allowMime;

protected $fileInfo;

protected $error;

protected $ext;

protected $destination;

protected $uniqid;


//構(gòu)造函數(shù),自己上傳的數(shù)據(jù)

public function __construct($fileName='myfile',

$maxSize=5242880,//5M

$endExt=array('jpg','jpeg','png','gif'),

$uploadPath='./uploads',

$flage=true,

$allowMime=array('image/jpg','image/jpeg','image/png','image/gif')

){

$this->fileName=$fileName;//瀏覽框名稱

$this->maxSize=$maxSize;//服務(wù)器端大小限制

$this->endExt=$endExt;//限制用戶只能在自己設(shè)置的后綴名稱內(nèi)上傳指定類型文件

$this->uploadPath=$uploadPath;//上傳到指定m目錄

$this->flage=$flage;//是否檢測(cè)文件類型

$this->allowMime=$allowMime;//通過文件類型來判斷該文件是否是惡意修改后綴來獲得上傳

$this->fileInfo=$_FILES[$this->fileName];//上傳文件的信息保存在變量fileInfo中

/*接收到上傳的信息$_FILES數(shù)組中自己要接受的fileName的信息*/

}

//判斷錯(cuò)誤號(hào),由于在對(duì)象內(nèi)使用,設(shè)置為私有

protected function checkERROR(){

if ($this->fileInfo['error']>0) {

switch ($fileInfo['error']) {

case 1:

$this->error='有錯(cuò)誤發(fā)生! UPLOAD_ERR_INI_SIZE :其值為1,上傳的文件超過了php.ini中的upload_max_filesize選項(xiàng)中限制的值';

break;

case 2:

$this->error='有錯(cuò)誤發(fā)生! UPLOAD_ERR_FORM_SIZE

:其值為2,上傳的文件大小超過了HTML表單中max_file_size限制的值';

break;


case 3:

$this->error='有錯(cuò)誤發(fā)生! UPLOAD_ERR_PARTIAL:其值為3,部分文件未上傳';

break;


case 4:

$this->error='有錯(cuò)誤發(fā)生! UPLOAD_ERR_NO_FILE:其值為4,沒有文件被上傳';

break;


case 6:?

https://img1.sycdn.imooc.com//5cd04b9400013a5a12570242.jpg

$this->error='有錯(cuò)誤發(fā)生! UPLOAD_ERR_NO_TMP_DIR:其值為6,找不到臨時(shí)文件夾';

break;


case 7:

$this->error='有錯(cuò)誤發(fā)生! UPLOAD_ERR_CANT_WRITE:其值為7,文件寫入失敗';

break;

case 8:

$this->error='有錯(cuò)誤發(fā)生! UPLOAD_ERR_EXTENSION:其值為8,上傳的文件被PHP擴(kuò)展程序中斷';

break;

}

return flase;

}

return true;

}

// 判斷文件大小是否符合規(guī)定

protected function checkMax(){

if ($this->maxSize<$this->fileInfo['size']) {

$this->error='上傳文件過大';

return flase;

}

return true;

}

//檢測(cè)擴(kuò)展名是否在允許的范圍內(nèi)

protected function checkExt(){

//用到了$ext,就設(shè)置一個(gè)$ext屬性

$this->ext=strtolower(pathinfo($this->fileinfo['name'],PATHINFO_EXTENSION));

if (!is_array($this->ext,$this->endExt)) {

$this->error='擴(kuò)展名不符合要求';

return flase;

}

return true;

}

//檢測(cè)上傳方式是否為post

protected function checkHttpPost(){

if (!is_uploaded_file($this->fileInfo['tmp_name'])) {

$this->error='上傳方式不符合要求';

return flase;

}

return true;

}

//檢測(cè)文件類型

protected function checkMime(){

if (!is_array($this->allowMime,$this->endExt){

$this->error='文件類型MIME非法';

return flase;

}

return true;

}

//檢測(cè)是否為一個(gè)真實(shí)的圖片

protected function checekimage(){

if ($this->flage) {

if (!getimagesize($this->fileInfo['tmp_name'])) {

$this->error='文件不是一個(gè)真實(shí)的圖片';

return flase;

}

return ture;

}

}

//顯示錯(cuò)誤

protected function ShowError(){

exit('<span style:"color=red"><strong>'.$this->error.'</strong></span>');

}

//判斷是否目錄名是否存在

protected function File(){

if (!file_exists($this->uploadPath)) {

mkdir($uploadPath,0777,true);

chmod($uploadPath,0777);

}

}

//上傳文件

public function uploadfile(){

if ($this->checkMax()&&$this->checkHttpPost()&&$this->checkMime()&&$this->checkExt()&&$this->checkERROR()&&checekimage()){

$this->uniqid=$this->setuniqid();

$this->destination=$this->uploadPath.'/'.$this->uniqid.'.'.$this->ext;

//移動(dòng)文件

if (@move_uploaded_file($this->fileInfo['tmp_name'],$this->destination)) {

return $this->destination;

}else{

$this->error='文件移動(dòng)失??!';

$this->ShowError();

}


}else{

$this->ShowError();

}

}


}



??>


正在回答

3 回答

頂不住了?你這個(gè)BUG比我的還多?我還想復(fù)制粘貼省事然后整到一半重新自己寫了

0 回復(fù) 有任何疑惑可以回復(fù)我~

is_array改成in_array試試行不行

0 回復(fù) 有任何疑惑可以回復(fù)我~

https://img1.sycdn.imooc.com//5cd04c4d0001308507550482.jpg

第107行上下的代碼在這里...

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

我又又又報(bào)錯(cuò)了...

我要回答 關(guān)注問題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)