I\'m using PHP to upload an image from a form to the server and want to rename the image lastname_firstname.[original extension]. I currently have:
move_upl
You need to first find out what the original extension was ;-)
To do that, the pathinfo function can do wonders ;-)
Quoting the example that's given in the manual :
$path_parts = pathinfo('/www/htdocs/index.html');
echo $path_parts['dirname'], "\n";
echo $path_parts['basename'], "\n";
echo $path_parts['extension'], "\n";
echo $path_parts['filename'], "\n"; // since PHP 5.2.0
Will give you :
/www/htdocs
index.html
html
index
As a sidenote, don't forget about security :
$_POST[lastname], to make sure it only contains valid characters
$_POST['lastname'] -- see Why is $foo[bar] wrong?