Closed (won't fix)
Project:
Drupal core
Version:
5.1
Component:
file system
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
16 Feb 2007 at 13:51 UTC
Updated:
20 Jun 2011 at 01:28 UTC
Not sure about other functions, but in this one I have found, that you are using '/' instead of DIRECTORY_SEPARATOR constant for creating paths to directories. This has caused me some issues with Windows mashine, as it didn't recognized the path 'c:\path\to\somewhere/file.txt' (note that last '/' instead of '\'). PHP has DIRECTORY_SEPARATOR constant specific to the platform it was installed on, which lots of developers likes to use as
define ('DS', DIRECTORY_SEPARATOR);
in the bootstrap phase for shorter further code.
Small example:
...
$source = $_FILES['files']['tmp_name']['my_field'];
$destination = 'c:\path\to\somewhere';
if (file_move($source, $destination, FILE_EXISTS_RENAME)) { // file_move() uses function file_copy()
rename($source, '...'); // Windows will try to locate that $source file with '/' in it's path and will not find it, althoug the file will be present on that directory if you would use '\' instead of '/'
}
...
Hope that makes sense, just use DIRECTORY_SEPARATOR in the future.
Thank you.
Comments
Comment #1
dpearcefl commentedConsidering the age of this issue with no comments and that Drupal 5 is no longer supported, I'm closing this ticket.