首页 >社区问答列表 >多图上传,怎样把上传路径写入到数据库中

多图上传,怎样把上传路径写入到数据库中

实现了多图上传,上传的文件夹都有图片,但是上传到数据库只有一条数据,我要怎么做,我要怎么写控制器

html代码<input type="file" name="image[]" /> <br> 

控制器要怎么写,求指导

  • RAUL
  • RAUL     2017-07-28 15:33:37 2楼

    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] => "    

    )    


    +0 添加回复

  • 回复