Mehrbild-Upload, wie schreibe ich den Upload-Pfad in die Datenbank?
RAUL
RAUL 2017-07-28 14:36:22
0
2
1505

Mehrere Bild-Uploads wurden implementiert, aber es wird nur ein Datenelement in die Datenbank hochgeladen. Wie soll ich den Controller-Code schreiben? " name="image []" /> <br>

Wie man den Controller schreibt, bitte Anleitung

RAUL
RAUL

Antworte allen(2)
RAUL

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] => think\File Object    

(    

[error:think\File:private] =>    

[filename:protected] => C:\wamp\tmp\phpC8C2.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:\wamp\tmp\phpC8C2.tmp    

[error] => 0    

[size] => 40090    

)    

[hash:protected] => Array    

(    

)    

[pathName:SplFileInfo:private] => C:\wamp\tmp\phpC8C2.tmp    

[fileName:SplFileInfo:private] => phpC8C2.tmp    

[openMode:SplFileObject:private] => r    

[delimiter:SplFileObject:private] => ,    

[enclosure:SplFileObject:private] => "    

)    


猪哥

打印数据后就能看到 数据结构 按这个结构处理就行了


Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage