I'm assuming you are familiar with the image manipulation functions in PHP, so that I don't need to explain how to make thumbnails:
If so, there are a few options. I'd explode it, then get the name by popping off the extension and imploding it:
$fn = $_FILES['myfile']['filename']; // get uploaded file name
$fn = explode(".", $fn); // split into array around periods
$ext = array_pop($fn); // remove last element of array; set aside as extension
$fn = implode(".", $fn); // rejoin file name minus extension
//code to make thumbnail
$tn = "$fn.thumbnail.$ext"; // thumbnail name
$fn = "$fn.$ext"; // file name rejoined with extension
The above assumes all files will come with an extension of some sort; however, if there is no extension, and the file name has a period in it, this will mess up the name.
For example, if I upload a file named:
mypic.isnice.jpg
The code above will set $fn to be:
mypic.isnice
However, if I upload a file named:
mypic.isnice
The code above will set $fn to be:
mypic
A way to work around that is to add a regular expression that checks for one- to four-letter file extensions and executes the code only if there is one:
$fn = $_FILES['myfile']['filename']; // get uploaded file name
if(eregi( '^.*[a-z]{1,4}$', $fn )) {
$fn = explode(".", $fn); // split into array around periods
$ext = array_pop($fn); // remove last element of array; set aside as extension
$fn = implode(".", $fn); // rejoin file name minus extension
//code to make thumbnail
$tn = "$fn.thumbnail.$ext"; // thumbnail name
$fn = "$fn.$ext"; // file name rejoined with extension
}
Or, you could change the regular expression to check for specific file extensions:
$fn = $_FILES['myfile']['filename']; // get uploaded file name
if(eregi( '^.*(.jpg)|(.jpeg)$', $fn)) {
$fn = explode(".", $fn); // split into array around periods
$ext = array_pop($fn); // remove last element of array; set aside as extension
$fn = implode(".", $fn); // rejoin file name minus extension
//code to make thumbnail
$tn = "$fn.thumbnail.$ext"; // thumbnail name
$fn = "$fn.$ext"; // file name rejoined with extension
}