I'm using PHP rename() function to move a file. The file has space in the filename though. And for some reason it can't find it. I tried escaping it but that didn't work either. Does someone have an idea what is going on? It is on a Unix system.
$filename = basename($file->uri);
// Tried this once didn't work either:
$filename = str_replace(' ', "\ ", $filename);
//
rename($_SERVER['DOCUMENT_ROOT'].$source.'/'.$filename,
drupal_realpath($file->uri));
Thank you very much in advance.
I don't think it's space issue. Probably simple your file doesn't exist in the path you give to rename function.
Try to display the path:
echo $_SERVER['DOCUMENT_ROOT'].$source.'/'.$filename;
and make sure this path is really valid in your case
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.