php tmp_name没有值,php – $_FILES字段’tmp_name’对.JPG文件扩展名没有任何值

如果$ _FILES [$ field] [‘tmp_name’]为空,则文件尚未上传。你应该看看$ _FILES [$ field] [‘error’]看看为什么。

FWIW,据我所知,$ _FILES []中的MIME类型由浏览器提供。

更新:这里是一个盆栽代码来处理所有文件上传错误:

$message = 'Error uploading file';

switch( $_FILES['newfile']['error'] ) {

case UPLOAD_ERR_OK:

$message = false;;

break;

case UPLOAD_ERR_INI_SIZE:

case UPLOAD_ERR_FORM_SIZE:

$message .= ' - file too large (limit of '.get_max_upload().' bytes).';

break;

case UPLOAD_ERR_PARTIAL:

$message .= ' - file upload was not completed.';

break;

case UPLOAD_ERR_NO_FILE:

$message .= ' - zero-length file uploaded.';

break;

default:

$message .= ' - internal error #'.$_FILES['newfile']['error'];

break;

}

if( !$message ) {

if( !is_uploaded_file($_FILES['newfile']['tmp_name']) ) {

$message = 'Error uploading file - unknown error.';

} else {

// Let's see if we can move the file...

$dest .= '/'.$this_file;

if( !move_uploaded_file($_FILES['newfile']['tmp_name'], $dest) ) { // No error supporession so we can see the underlying error.

$message = 'Error uploading file - could not save upload (this will probably be a permissions problem in '.$dest.')';

} else {

$message = 'File uploaded okay.';

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值