Multi-image upload, how to write the upload path into the database
RAUL2017-07-28 14:36:22
0
2
1442
I have implemented multiple image uploads. The uploaded folders all have images, but there is only one piece of data uploaded to the database. What should I do? How should I write the controller?
public function upload(){
// Get the form upload file, for example, uploaded 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');
}
How do I get the image name of the multi-dimensional array in a loop
The following is the printed
Array
(
[0 ] => thinkFile Object
(
[error:thinkFile:private] =>
[rule :protected] => date [validate:protected] => Array ( ) [isTest:protected] => ( [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] => "
)
You can see the data structure after printing the data. Just process it according to this structure