84669 人学习
152542 人学习
20005 人学习
5487 人学习
7821 人学习
359900 人学习
3350 人学习
180660 人学习
48569 人学习
18603 人学习
40936 人学习
1549 人学习
1183 人学习
32909 人学习
实现了多图上传,上传的文件夹都有图片,但是上传到数据库只有一条数据,我要怎么做,我要怎么写控制器
html代码<input type="file" name="image[]" /> <br>
控制器要怎么写,求指导
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] => "
打印数据后就能看到 数据结构 按这个结构处理就行了
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] => "
)
打印数据后就能看到 数据结构 按这个结构处理就行了