dqpkea9486 2018-05-07 08:45
浏览 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条)

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?