如何将多个文件路径内嵌到单个mysql数据库字段中

时间:2017-11-09 20:38:09

标签: php mysql

我试图从文件中破坏我的图像目的地的路径。但撞墙。

这是上传脚本

 <?php 
        if(!empty($_FILES['files']['name'][0])){
        $files=$_FILES['files'];
        $uploaded= array();
        $failed= array();
        $allowed= array('jpg','png','jpeg');

        foreach ($files['name'] as $position => $file_name){
            $file_tmp =  $files['tmp_name'][$position];
            $file_size = $files['size'][$position];
            $file_error= $files['error'][$position];


            $file_ext= explode('.',$file_name);
            $file_ext= strtolower(end($file_ext));

            if(in_array($file_ext, $allowed)){
                if($file_error===0){
                    if($file_size <= 2097152){
                        $file_name_new=uniqid('',true).'.'.$file_ext;
                        $file_destination='uploads/'.$file_name_new;

                        if(move_uploaded_file($file_tmp, $file_destination)){
                            $uploaded[$position]=$file_destination;
                        }else{
                              $failed[$position]="[{$file_name}] failed to 
            upload'";
                        }
                    }else{
                    $failed[$position]="[{$file_name}]'file 
         extension'{$file_size}' too big'";
                    }
                }else{
                    $failed[$position]="[{$file_name}]'file 
            extension'{$file_ext}' is not allowed'";
                }
            }else{
                $failed[$position]="[{$file_name}]'file extension'{$file_ext}' is not allowed'";
            }
        }
           } ?>

这是sql查询。我不知道自己错过了什么。我试图插入图片字段。

 $query=$dbc->query("insert into  classifieds(post_id,poster_id,poster_name,title,poster_email,poster_number,category,description,location,images) 
                values('$post_id','$user_id_get','$name','$title','$email','$phone','$category','$description','$location','$file_destination')
                ");

0 个答案:

没有答案