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

為了賬號安全,請及時綁定郵箱和手機立即綁定

doAction5,php中dest未定義索引

doAction5,php

<?php

// print_r($_FILES);


require_once 'upload.func1.php';

require_once 'common.func.php';

$files=getFiles();

// print_r($_FILES);

foreach($files as $fileInfo){

$res=uploadFile($fileInfo);

echo $res['mes'],'<br/>';

$uploadFiles[]=$res['dest'];

}

$uploadFiles=array_values(array_filter($uploadFiles));

print_r($uploadFiles);




upload.func1.php

<?php


function getFiles(){

$i=0;

foreach($_FILES as $file){

if(is_string($file['name'])){

$files[$i]=$file;

$i++;

}elseif(is_array($file['name'])){

foreach($file['name'] as $key=>$val){

$files[$i]['name']=$file['name'][$key];

$files[$i]['type']=$file['type'][$key];

$files[$i]['tmp_name']=$file['tmp_name'][$key];

$files[$i]['error']=$file['error'][$key];

$files[$i]['size']=$file['size'][$key];

$i++;

}

}

}

return $files;

}






function uploadfile($fileInfo,$path='./uploads',$flag=true,$maxSize=1048576,$allowExt=array('jpeg','jpg','gif','png')){

// $flag=true;

// $allowExt=array('jpeg','jpg','gif','png');

// $maxSize=1048576;//1m

//判斷錯誤號

if($fileInfo['error']===UPLOAD_ERR_OK){

? ? if($fileInfo['size']>$maxSize){

$res['mes']=$fileInfo['name'].'上傳文件過大';

}

$ext=getExt($fileInfo['name']);

if(!in_array($ext,$allowExt)){

$res['mes']=$fileInfo['name'].'非法文件類型';

// 檢測是否是真的圖片類型

}

if($flag){

? ? if(!getimagesize($fileInfo['tmp_name'])){

? ? $res['mes']=$fileInfo['name'].'不是真實圖片類型';

}

}

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

$res['mes']=$fileInfo['name'].'文件不是通過HTTP POST方式上傳上來的';

}

if (!empty($res)) return $res;

??

// $path='./uploads';

if(!file_exists($path)){

mkdir($phat,0777,true);

chmod($phat,0777);

?

}

$uniName=getUniName();

$destination=$path.'/'.$uniName.'.'.$ext;

? ?if(!move_uploaded_file($fileInfo['tmp_name'],$destination)){

? ? ? ? ? ?$res['mes']=$fileInfo['name'].'文件移動失敗';

? ? ? ? }

$res['mes']=$fileInfo['name'].'上傳成功';

$res['dest']=$destination;

return $res; ??

}else{

//匹配錯誤信息

switch ($fileInfo ['error']) {

? ? ? ? ?case 1 :

? ? ? ? ? ? $mes = '上傳文件超過了PHP配置文件中upload_max_filesize選項的值';

? ? ? ? ? ? break;

? ? ? ? ?case 2 :

? ? ? ? ? ? $mes = '超過了表單MAX_FILE_SIZE限制的大小';

? ? ? ? ? ? break;

? ? ? ? ?case 3 :

? ? ? ? ? ? $mes = '文件部分被上傳';

? ? ? ? ? ? break;

? ? ? ? ?case 4 :

? ? ? ? ? ? $mes = '沒有選擇上傳文件';

? ? ? ? ? ? break;

? ? ? ? ?case 6 :

? ? ? ? ? ? $mes = '沒有找到臨時目錄';

? ? ? ? ? ? break;

? ? ? ? ?case 7 :

? ? ? ? ?case 8 :

? ? ? ? ? ? $mes = '系統(tǒng)錯誤';

? ? ? ? ? ? break;

? ? ? }

? ? ? echo ( $mes );

? ? ? return false;

? ?}

? ?$ext = pathinfo ( $fileInfo ['name'], PATHINFO_EXTENSION );

//? ? ?$allowExt = array (

//? ? ? ? ? ?'jpeg',

//? ? ? ? ? ?'jpg',

//? ? ? ? ? ?'png',

//? ? ? ? ? ?'gif'?

//? ? ?);

? ?if(!is_array($allowExt)){

? ? ? exit('系統(tǒng)錯誤');

? ?}

? ?// 檢測上傳文件的類型

? ?if (! in_array ( $ext, $allowExt )) {

? ? ? exit ( '非法文件類型' );

? ?}

? ?//$maxSize = 2097152; // 2M

? ? ? ? ? ? ? ? ? ? ?// 檢測上傳文件大小是否符合規(guī)范

? ?if ($fileInfo ['size'] > $maxSize) {

? ? ? exit ( '上傳文件過大' );

? ?}

? ?//檢測圖片是否為真實的圖片類型

? ?//$flag=true;??

? ?if($flag){

? ? ? if(!getimagesize($fileInfo['tmp_name'])){

? ? ? ? ?exit('不是真實圖片類型');

? ? ? }

? ?}

? ?// 檢測文件是否是通過HTTP POST方式上傳上來

? ?if (! is_uploaded_file ( $fileInfo ['tmp_name'] )) {

? ? ? exit ( '文件不是通過HTTP POST方式上傳上來的' );

? ?}

? ?//$uploadPath = 'uploads';

? ?if (! file_exists ( $uploadPath )) {

? ? ? mkdir ( $uploadPath, 0777, true ); //創(chuàng)建一個upload文件夾,0777表示可讀可寫可執(zhí)行

? ? ? chmod ( $uploadPath, 0777 );

? ?}

? ?$uniName = md5 ( uniqid ( microtime ( true ), true ) ) . '.' . $ext;

? ?$destination = $uploadPath . '/' . $uniName;

? ?if (! @move_uploaded_file ( $fileInfo ['tmp_name'], $destination )) {

? ? ? exit ( '文件移動失敗' );

? ?}

? ?

? ?//echo '文件上傳成功';

//? ? ?return array(

//? ? ? ? 'newName'=>$destination,

//? ? ? ? 'size'=>$fileInfo['size'],

//? ? ? ? 'type'=>$fileInfo['type']

//? ? ?);

? ?return $destination;

}






正在回答

1 回答

執(zhí)行 `$res=uploadFile($fileInfo);`這段代碼返回的結果數(shù)組中,沒有dest鍵,所以才會報這個錯誤。

要看看代碼執(zhí)行到哪一步返回了?如果在$res['dest']賦值之前返回,返回的結果中就沒有dest鍵

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

doAction5,php中dest未定義索引

我要回答 關注問題
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號