![]() |
Renaming Uploaded Files
Hey,
Have made a script that basically uploads a file... nothing special. I wanted to rename each file with the user's username, so if my username is Test User the file would rename to test_user.ext. When I echo out the username and file name, they appear correct, but when I upload the image, it renames it to Array.ext. Not sure why it's outputting as an array, when I echo it out normally, it shows. Here's some code: PHP Code:
Thanks |
PHP Code:
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. |
Wiked!
Thank you Salathe :) |
| All times are GMT. The time now is 03:30 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0