title: How to copy a file with spaces and fullstops in the filename using using php's copy function?
body: <p>Consider the following snippet of code:</p>
  
  <pre><code>if (!copy($productdetails['img'][0], "../tempimages/".basename($product['img'][0]))) 
  {
      //error and exit or whatever
  }
  </code></pre>
  
  <p>An example of a filename that fails is <code>"proView.MHL H.jpg"</code>.</p>
  
  <p>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.</p>
  
  <p>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?</p>
  
  <p>The awful practice of putting spaces and full stops in a filename is out of my hands in this case.</p>
  
  <p>Thank you.</p>
  
  <p><strong>EDIT</strong>
  Sorry about forgetting the error message, which is as follows </p>
  
  <p><strong><em>Warning: copy(<a href="http://www.private.co.za/proView.MHL" rel="nofollow">http://www.private.co.za/proView.MHL</a> H.jpg): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in C:\websites\schosting\copytest.php on line 4</em></strong></p>