Page 1 of 1
File Upload
Posted: Tue Nov 15, 2011 1:11 pm
by spacebiscuit
Hi,
i'm using the following function to upload images:
Code: Select all
move_uploaded_file($_FILES['cover']['tmp_name'],$path);
It works but I want to give the file a name of my choosing, at present it uses the original file name.
Is this possible?
Re: File Upload
Posted: Tue Nov 15, 2011 1:14 pm
by Celauran
$path is user-defined so, strictly speaking, you're already doing that.
Code: Select all
$filename = "whatever";
$moved = move_uploaded_file($_FILES['cover']['tmp_name'], $path . DIRECTORY_SEPARATOR . $filename);
Re: File Upload
Posted: Tue Nov 15, 2011 1:24 pm
by spacebiscuit
Perfect that worked!
I did not realise that I had already been setting the filename in my code here:
Code: Select all
$path=$dir . basename( $_FILES['cover']['name']);
I just removed the basename() function and added my own filename.
Thanks!