Ciao a tutti,
ho bisogno di creare una thumb dopo un upload di una foto (jpg) tramite form.
Ho preso da php.net un codice già pronto, che effettivamente mi crea la thumb ma questa viene generata tutta nera.
Questo è il codice:
Codice PHP:
if( ($_FILES["file"]["type"] == "image/jpeg") ||
($_FILES["file"]["type"] == "image/jpg") ||
($_FILES["file"]["type"] == "image/pjpeg")
) {
$filename = $_FILES['file']['tmp_name'];
// Content type
header('Content-Type: text/jpeg');
// Get new sizes
list($width, $height) = getimagesize($filename);
$newwidth = 100;
$newheight = 100;
// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);
// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
// Output
imagejpeg($thumb, '../../media/'.$media_id.'/thumb_'.$_FILES['file']['tmp_name'], 70);
}
Dove può essere l'errore?
Grazie!