coderama coderama - 1 year ago 113
PHP Question

PHP Copy command failing when spaces?

I am executing the following commands:

copy ("http://localhost/.../DSCF8253.JPG" , "sites/default/files/DSCF8253.JPG"); // Success!
copy ("http://localhost/.../DSCF8260.JPG" , "sites/default/files/DSCF8260.JPG"); // Success!
copy ("http://localhost/.../HERMAN 085.jpg" , "sites/default/files/HERMAN 085.jpg" ); // Fail!

The first two copy fine, but not the last one. Why?

It must have something to do with the filenames (the last one has a SPACE before the 085).

Any help would be greatly appreciated!

Answer Source
http://localhost/.../HERMAN 085.jpg

Should be


Copy & the http wrappers are less forgiving then browsers / user-agents when it comes to invalid urls. A space in an url is invalid, so it should be urlencode'd.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download