Consider the following snippet of code:
if (!copy($productdetails['img'][0], "../tempimages/".basename($product['img'][0])))
{
//error and exit or whatever
}
An example of a filename that fails is "proView.MHL H.jpg"
.
The file is being copied from one website to another (Linux servers). Both inputs have to variables, i.e. I cannot hard code any filenames. Solution cannot use any shell commands either.
How can I still get the file to copy if it contains invalid characters such as spaces, and even the odd slash, Assuming it's possible of course?
The awful practice of putting spaces and full stops in a filename is out of my hands in this case.
Thank you.
EDIT Sorry about forgetting the error message, which is as follows
Warning: copy(http://www.private.co.za/proView.MHL H.jpg): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in C:\websites\schosting\copytest.php on line 4