View Single Post
Old 10-17-2007, 10:12 PM   #2 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

PHP Code:
// Old, wrong
$file_name str_replace($ext[0], strtolower($info['username']), $ext);

// New, slightly better
$file_name str_replace($ext[0], strtolower($info['username']), $_FILES['upload_avatar']['name']); 
You were trying to do a string replacement (str_replace()) on an array ($ext). If you read the PHP manual page, you'd know that if an array is used then the return value is also an array. Because of that, when you try to put together the $directory variable, PHP converts the $file_name array into a string: "Array". That's why your files were being called Array.ext.
Salathe is offline  
Reply With Quote