I want the variable $thename to be the name of the uploaded file. I also am trying to make a thumbnail and it makes it and names it properly but its just solid black.
$file = $_FILES['image']['name'];
if (substr($file, -3) == 'jpg') {
$thename = mysql_insert_id();
$target_path = "./flyer/" . $_FILES['image']['name'];
if (is_uploaded_file($_FILES['image']['tmp_name'])) {
if (move_uploaded_file($_FILES['image']['tmp_name'], $target_path)) {
$save = './flyer/thumb'.$thename.'.jpg';
list($width, $height) = getimagesize($file) ;
$modwidth = '108';
$modheight = '142';
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save, 100) ;
} else{
echo "There was an error.";
}
} else {
echo 'File not uploaded.';
echo $_FILES['image']['error'];
}
mysql_close();
} else {
exit('<p>You have not entered all required details or you tried to add a show with a date earlier than today.</p>');
}