0
     $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 is the if condition not checking whether image in that path already not exists... it simply enters into if condition so please help.

1 Answer 1

2

It happens because you dont check if file exists...

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

Your current code checks if condition is not false, which is not (it contains not empty string with path), but it have nothing to do with the fact that file exists or not.

File exists manual

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.