dqpkea9486 2018-05-07 08:45 采纳率: 100%
浏览 151
已采纳

如何在MySQL中以单行的形式获取以逗号分隔格式存储的图像?

I am uploading multiple images in the database in a single column with comma separated format. I am first creating a folder for each user and inside that folder, images are stored. car_images is my root directory inside that with the name of logged_in user new directory will create.

My images are stored in below format : enter image description here

Here, emp_code is unique I am using this as SESSION and for the name of the folder of each user. as you see car_images column where I am storing image name with ,. I am using below code to stored images in folders and database. I don't know idea how to fetch all images of a single user.

$car_images_all="";
        for($i=0; $i<count($_FILES['car_images']['name']); $i++) 
        {
           $tmpFilePath = $_FILES['car_images']['tmp_name'][$i];    
           if ($tmpFilePath != "")
            {    
                if (!file_exists('car_images/'.$emp_code)) 
                    {
                        mkdir('car_images/'.$emp_code, 0777, true);
                    }
                $location = 'car_images/'.$emp_code.'/';
               $name = $_FILES['car_images']['name'][$i];
               $size = $_FILES['car_images']['size'][$i];

               list($txt, $ext) = explode(".", $name);
               $file= time().substr(str_replace(" ", "_", $txt), 0);
               $info = pathinfo($file);
               $filename = $file.".".$ext;
               if(move_uploaded_file($_FILES['car_images']['tmp_name'][$i], $location.$filename)) 
               { 
                  $car_images_all.=$filename.",";
               }
            }
        }
  • 写回答

4条回答 默认 最新

  • dstd2129 2018-11-23 06:32
    关注
     <?php 
     $x=0;                                                
     $car_img =explode(",",$car_images);
     foreach($car_img as $car_images{                                                  
     $x+=1;0
     ?>                                                 
     <?php   echo '<img src="'."images/".$car_images.'" width="70" height="70" />';?>      
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?