Possible Duplicate:
How to convert all images to JPG format in PHP?
I'm trying to pass the username into the filename and have the file end with .jpg So the output would be "user-mycoolnewimage.jpg". Any suggestions on how to do this as currently is changes to "randnumber-mycoolnewimage.png" which isn't what I want. The random number doesn't help server logs and the image needs to end with jpg since it's being converted.
$file = rand(0, 10000000).$_FILES['t1']['name'];
if (move_uploaded_file($_FILES['t1']['tmp_name'], $file)) {
if($fp = fopen($file,"rb", 0)) {
$picture = fread($fp,filesize($file));
fclose($fp);
$image = imagecreatefrompng($file);
imagejpeg($image, $file, 70);
imagedestroy($image);
$tag1 = '<img src="'.$file.'" alt="" class="default" />';
//unlink($file);
}
}