Here's what I'm trying to do. I've got a form which has a field to upload an image. (input type="file" name="file") Anyway, what I'm trying to do... since I'm going to be putting these images into a database, is rename the image to a random image name.. I've gotten to the point where it would upload the image with a random number... but no extension....
function gfe($filename) //function to get image's extension
{
$pathinfo = pathinfo($filename);
return $pathinfo['extension'];
}
$extension = gfe($file); //calls function and puts the extension into a var
//this might be where I'm screwing up... I'm trying to generate a random number and then add the extension to it
$imgname = time() . $REMOTE_HOST . $extension;
//Then I have the copy function
copy($file, "/path/to/images/$imgname");
Any ideas where I went wrong, or an easier way to do this?
Renaming uploaded files with extension.
Moderator: General Moderators