php server side code to upload image -


     $path1='./upload/'.$userid.'/';        if(!$path1.$category_name.'_'.$i.'_product_image1.jpg')      {         $file1 = fopen($path1.$category_name.'_'.$i.'_product_image1.jpg', 'wb');         $file2 = fopen($path1.$category_name.'_'.$i.'_product_image2.jpg', 'wb');         $file3 = fopen($path1.$category_name.'_'.$i.'_product_image3.jpg', 'wb');          fwrite($file1, $binary1);         fwrite($file2, $binary2);         fwrite($file3, $binary3);          $path = $category_name.'_'.$i;  }      else {"already exists";}       $gimage1 = mysql_real_escape_string(base_url($path1.$path.'_product_image1.jpg'));      $gimage2 = mysql_real_escape_string(base_url($path1.$path.'_product_image2.jpg'));      $gimage3 = mysql_real_escape_string(base_url($path1.$path.'_product_image3.jpg'));       fclose($file1);      fclose($file2);      fclose($file3); 

why if condition not checking whether image in path not exists... enters if condition please help.

it happens because dont check if file exists...

if(!file_exists($path1.$category_name.'_'.$i.'_product_image1.jpg')); 

your current code checks if condition not false, not (it contains not empty string path), have nothing fact file exists or not.

file exists manual


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -