实现了多图上传,上传的文件夹都有图片,但是上传到数据库只有一条数据,我要怎么做,我要怎么写控制器
html代码<input type="file" name="image[]" /> <br>
控制器要怎么写,求指导
RAUL2017-07-28 15:33:37
public function upload(){
// 获取表单上传文件 例如上传了001.jpg
$files = Request::instance()->file('image');
foreach($files as $file){
$info = $file->move('upload');
}
print_r($files);exit;
$infos = $info->getFilename();
$date=date("Ymd",time());
$data = input('post');
$data['path'] = '/upload/'.$date.'/'.$infos;
$ret = model('Photo')->saveALL($data['path']);
$this->redirect('admin/product/index');
}
我要怎么循环拿到多维数组的图片名称
下面是打印的
Array
(
[0] => thinkFile Object
(
[error:thinkFile:private] =>
[filename:protected] => C:wamptmpphpC8C2.tmp
[saveName:protected] =>
[rule:protected] => date
[validate:protected] => Array
(
)
[isTest:protected] =>
[info:protected] => Array
(
[key] => image
[name] => 5.jpg
[type] => image/jpeg
[tmp_name] => C:wamptmpphpC8C2.tmp
[error] => 0
[size] => 40090
)
[hash:protected] => Array
(
)
[pathName:SplFileInfo:private] => C:wamptmpphpC8C2.tmp
[fileName:SplFileInfo:private] => phpC8C2.tmp
[openMode:SplFileObject:private] => r
[delimiter:SplFileObject:private] => ,
[enclosure:SplFileObject:private] => "
)