tp5.1循环上传会报错

浏览:489 发布日期:2019/06/03 分类:ThinkPHP5专区
报错信息:
SplFileobject::__construct(/Applications/MAMP/tmp/php/phpy8U4PW): failed to open stream: No such file or directory


/**
* 文件hash规则
* @var array
*/
protected $hash = [];

public function __construct($filename, $mode = 'r')
{
parent::__construct($filename, $mode);

$this->filename = $this->getRealPath() ?: $this->getPathname();
}

/**
* 是否测试
* @access public
* @param bool $test 是否测试
* @return $this


我的代码:
$data=input('post.');
//获取数据库所有的ename
$ename=db('conf')->column('ename');
$confArr=array();
//获取所有上传附件的name
$fileEname=db('conf')->where('dt_type',6)->column('ename');
//循环并修改数据库数据
foreach ($data as $k => $v) {
$confArr[]=$k;
if(is_array($v)){
$v=implode(',', $v);
}
db('conf')->where('ename',$k)->update(['value'=>$v]);
}
foreach ($ename as $k => $v) {
if(!in_array($v, $confArr) && !in_array($v, $fileEname)){
db('conf')->where('ename',$v)->update(['value'=>'']);
}
}
//附件类型数据处理
// dump($fileEname);die;
foreach($fileEname as $k=>$v){
if($_FILES[$v]['tmp_name']){
$file = request()->file($v);
$info = $file->move( '../uploads');
if($info){
// 成功上传后 获取上传信息
// 输出 jpg
// 输出 42a79759f284b767dfcb2a0197904287.jpg
echo $info->getFilename();
}else{
// 上传失败获取错误信息
echo $file->getError();
}
}

}


请各位大哥帮忙看看,tp5.0是可以正常上传的同样的代码
最佳答案
评论( 相关
后面还有条评论,点击查看>>