但是photo是多张上传的,却报错 未知错误,希望大家帮忙解决一下。
代码如下:
HTML:
<input type="file" name="logo" />
<input type="file" name="photo[]" />
<input type="file" name="photo[]" />
<input type="file" name="photo[]" />php:if ($_FILES['logo']['name'] != NULL) {
$upload = new \Think\Upload();
$upload -> maxSize = 3000000;
$upload -> exts = array('jpg', 'gif', 'png', 'jpeg');
$savePath = '/Uploads/';
$uppath = './Uploads/';
if (!is_dir($uppath)) {
if (!mkdir($uppath, 0755, TRUE)) {
$this -> error('创建上传目录失败,请检查根目录是否有写入权限!');
}
}
$info = $upload -> upload();
if (!$info) {
$this -> error($upload -> getError());
}
$thumb = $savePath . $info['logo']['savepath'] . $info['logo']['savename'];
$logo['logo'] = $thumb;
}//这里可以上传成功
if (!empty($_FILES['photo']['name'][0])) {
p($_FILES['photo']);
//exit;
$upload = new \Think\Upload();
$upload -> maxSize = 3000000;
$upload -> exts = array('jpg', 'gif', 'png', 'jpeg');
$savePath = '/Uploads/';
$uppath = './Uploads/';
if (!is_dir($uppath)) {
if (!mkdir($uppath, 0755, TRUE)) {
$this -> error('创建上传目录失败,请检查根目录是否有写入权限!');
}
}
$info = $upload -> upload($_FILES['photo']['name']);
if (!$info) {
$this -> error($upload -> getError());
}
foreach ($info as $key => $photo) {
$data['photo'] = $savePath . $photo['savepath'] . $photo['savename'];
$data['pid'] = $aid;
$res = $this -> photo_model -> data($data) -> add();
if (!$res) {
$this -> error('图片增加时出现错误!');
}
}
}//报错,上传未知错误 最佳答案