Advertisement
Guest User

function saveImage($barcode)

a guest
Jul 26th, 2016
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.82 KB | None | 0 0
  1. <?php
  2.  
  3.         function saveImage($barcode)
  4.         {
  5.             if(is_numeric($barcode))
  6.             {
  7.  
  8.             $qw = $this->PDO->query("SELECT `BARCODE`, `IMAGE`, `PHOTO_NUM` FROM `photo` WHERE `BARCODE`='".$barcode."' LIMIT 0, 32");
  9.                        
  10.             if($qw->fetchColumn()>0)
  11.                 {
  12.                    
  13.                     while($row = $qw->fetch())
  14.                     {
  15.                         $mark = $this->getMark($row['BARCODE']);
  16.                        
  17.                         if(!file_exists($this->app_path.'\images\\'.$mark))
  18.                         {
  19.                             mkdir($this->app_path.'\images\\'.$mark, 0777);
  20.                         }          
  21.                        
  22.                         $img_path=$this->app_path.'\images\\'.$mark.'\\'.$row['BARCODE'].'-'.$row['PHOTO_NUM'].'.jpg';
  23.                         if(!file_exists($img_path))
  24.                         {
  25.                             file_put_contents($img_path, $row['IMAGE']);
  26.                         }
  27.                            
  28.                     }
  29.                 }
  30.                 else
  31.                 {
  32.                     return false;
  33.                 }
  34.             }  
  35.             else
  36.             {
  37.                 return false;
  38.             }
  39.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement