Forum Moderators: coopster
$SWFexten = findexts($_FILES['file']['name']);
$PNGexten = findexts($_FILES['prefile']['name']);
$targeSWF = "res/bin/art/art".$currentStamp.".".$SWFexten;
$targePNG = "res/bin/preview/temp".$currentStamp.".".$PNGexten;
$targeJPG = "res/bin/preview/art".$currentStamp.".jpg";
if(move_uploaded_file($_FILES['prefile']['tmp_name'],$targePNG)) {
$save = $targeJPG;
$file = $targePNG;
header('Content-type: image/jpeg');
list($width, $height) = getimagesize($file);
$modwidth = 70;
$modheight = 70;
$tn = imagecreatetruecolor($modwidth, $modheight);
$image = imagecreatefromjpeg($file);
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height);
imagejpeg($tn, $save, 100);
unlink($targePNG);
}
but whenever I try something like this:
$SWFexten = findexts($_FILES['file']['name']);
$PNGexten = findexts($_FILES['prefile']['name']);
$targeSWF = "res/bin/art/art".$currentStamp.".".$SWFexten;
$targePNG = "res/bin/preview/temp".$currentStamp.".".$PNGexten;
$targeJPG = "res/bin/preview/art".$currentStamp.".png";
if(move_uploaded_file($_FILES['prefile']['tmp_name'],$targePNG)) {
$save = $targeJPG;
$file = $targePNG;
header('Content-type: image/png');
list($width, $height) = getimagesize($file);
$modwidth = 70;
$modheight = 70;
$tn = imagecreatetruecolor($modwidth, $modheight);
$image = imagecreatefrompng($file);
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height);
imagepng($tn, $save, 100);
unlink($targePNG);
}
It throws errors at me..
What am I doing wrong?
PS: I want to do the same for .GIF files too (and I want to keep transparency)
[edited by: NogginAnimations at 9:50 am (utc) on Aug. 29, 2008]
And, in both cases, you don't need to send an output header if you are saving the output to disk... but, presumably, you are then using readfile or an additional image* call to output to the browser.
Other than that, it'd be a great help to know what errors it is actually returning. :)