PHP: file_exists () and copy () in paths with spaces

The system I'm working on is CentOS 6. Suppose I have this file path: /var/www/examplesite.com/uploads/Dog Photos/happy dog.jpg

For whitespace support, I run a simple $filepath = str_replace(' ', '\\ ', $filepath)

one to avoid whitespace.

This will result in a new file path: /var/www/examplesite.com/uploads/Dog\ Photos/happy\ dog.jpg

However it file_exists($filepath)

returns false.

It's odd because it stat /var/www/examplesite.com/uploads/Dog\ Photos/happy\ dog.jpg

returns the correct information about the file.

What am I doing wrong?

+3


source to share


1 answer


Share folder 777 to access this folder. Also, when uploading a file, you can change the filename by simply inserting an underscore instead of a space.



0


source







All Articles