Hello
I have the following script that I created to enable uploading the same image, giving each image I upload a unique id. however the file contains no extension. Can anyone see what I did wrong here?
function getExtension($typeOf) {
if ($typeOf == 'image/gif') {
return '.gif';
} else if ($typeOf == 'image/jpeg') {
return '.jpg';
} else if ($typeOf == 'image/png') {
return '.png';
} else if ($typeOf == 'image/vnd.wap.wbmp') {
return '.wbmp';
}
}
/**********************************************
--- CREATE UNIQUE IDS FOR IMAGES ---
**********************************************/
if ($_FILES['image_1']['name']) {
$uniqueImagePart1 = md5(date('h-s'));
$uniqueImagePart1 = substr($uniqueImagePart1,0,5);
$uniqueImagePart2 = md5($_FILES['image_1']['name']);
$uniqueImagePart2 = substr($uniqueImagePart2,0,5);
$uniqueImage1 = $uniqueImagePart1 . $uniqueImagePart2 . getExtension($_FILES['image_1']['type']);
//echo '<br><br>'.$uniqueImage1;
when i echo the $uniqueImage1 I see the file but when I copy it there is no extension?
Here is my copy script
if (!empty($_FILES['image_1']['name'])) {
copy ($_FILES['image_1']['tmp_name'],'articles/'.$uniqueImage1);
}
any help would be appreciated. Stangely enough the image show up in the browser no problem however contains no extension?