resize - Create image and rename is not working in PHP -


i need create process making images different dimensions , move them repective folder.the below code working images , not some.some images being renamed in subfolder , not.some images being created , not.i have performed unit testing on single image , works.but when run on server,i above problem.there more 500 images needs processed.i not able understand went wrong.please help.

    $arr=array();     $arr["popup"]=array("width"=>228,"height"=>304);     $arr["zoom"]=array("width"=>1500,"height"=>2000);     $source = imagecreatefromjpeg($file_path);           list($width, $height) = getimagesize($file_path);      foreach($arr $image_type=>$dimention){            echo "<br> $image_type : ";         $temp_folder_name=$image_type;                     $temp_folder_path='../prod_images/'.$folder_name.'/'.$temp_folder_name;          //check if directory exists if not create else traverse         if (!file_exists($temp_folder_path)):             mkdir($temp_folder_path);         else:             $files = glob($temp_folder_path.'/'.$filename);             if (!empty($files))){                 echo "<br/>images exists";                 $curr_dt = date('ymd_his');                 $dt = '_'.$curr_dt;                 $file_arr = explode(".",$filename);                 $new_filename = $file_arr[0].$dt.'.'.$file_arr[1];                  $oldname = '../prod_images/'.$folder_name.'/'.$temp_folder_name.'/'.$filename;                 echo "<br>old name : ".$oldname;                 $newname = '../prod_images/'.$folder_name.'/'.$temp_folder_name.'/'.$new_filename;                 echo "<br>new name : ".$newname;                 rename($oldname,$newname);             }else{                 echo "<br/>images not exist";              }         endif;          $curr_width=$dimention["width"];         $curr_height=$dimention["height"];         echo "<br> $image_type - $curr_width - $curr_height";         $temp_image = imagecreatetruecolor($curr_width, $curr_height);         //imagecopyresized($temp_image,$source, 0, 0, 0, 0, $curr_width, $curr_height, $width, $height);         imagecopyresampled($temp_image,$source, 0, 0, 0, 0,$curr_width, $curr_height, $width, $height);                  imagejpeg($temp_image,$temp_folder_path."/".$filename);          imagedestroy($temp_image); 

according me, code seems ok. might need check rights on files , folder. type ls -l on 1 of folder or, don't recommend sudo chmod 777 -r ./ think best way check if server has right write , read /prod_images/ folder.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -