Welcome Guest, Not a member yet? Register   Sign In
Problem with move() and file exists (SOLVED)
#3

Thank you for your reply.

For the following source code:

PHP Code:
    private function manageFiles($files$id$thumb false)
    {

        $db              = \Config\Database::connect();
        $builderImages   $db->table('images');

        foreach ($files['theFile'] as $file) {
            if ($file->isValid() && !$file->hasMoved()) {

                $newName $file->getRandomName();
                $file->move('./uploads/'$newName);

                $dataImages = [
                    'name' => $newName,
                    'galeries_id'  => $id,
                ];
                $builderImages->insert($dataImages);

                $image_path base_url() . '/uploads/' $newName;

                // just before the if statement.
                echo $image_path;
                exit();

                if (!file_exists($image_path)) :
                    echo $image_path;
                    echo 'wrong_path';     // ==> Always !!
                endif;

                if ($thumb) {

                    $image_dest '"' base_url() . '/uploads/330x200_' $newName '"';
                    $return $this->resize_img($image_path$image_dest33080'auto'true);
                    echo $return;
                }
            }
        }
    

It give me the correct image path, this path points to an image, the browser finds it when I try to search for it with.
As the following screenshot shows:


[Image: kxn6.jpg]
In this topic, we can read the following: file exists doesn't work with http address

https://stackoverflow.com/questions/6930...does-exist
Reply


Messages In This Thread
RE: Problem with move() and file exists - by neoneeco - 11-20-2020, 04:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB