dezkit Posted November 6, 2008 Share Posted November 6, 2008 Hey guys, I have this code that i made, and it displays a black image, instead of the original image when uploaded <?php if($submit == "Upload File"){ function findexts ($filename) { $filename = strtolower($filename) ; $exts = split("[/\\.]", $filename) ; $n = count($exts)-1; $exts = $exts[$n]; return $exts; } $ext = findexts ($_FILES['file']['name']) ; $ran = rand(); $ran2 = $ran."."; $sein = "./uploads/"; $target = "./uploads/"; $target = $target . $ran2.$ext; $fale = $ran2.$ext; if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "<font color=\"red\" size=\"+1\">Image has been uploaded!</font><br><br>"; if (file_exists("./uploads/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], $target); $uploadedfile = $target; $src = imagecreatefromjpeg($uploadedfile); // Script beginning, please check list($width,$height)=getimagesize($uploadedfile); $newwidth=600; $newheight=($height/$width)*600; $tmp=imagecreatetruecolor($newwidth,$newheight); $filename = $target; imagejpeg($tmp,$filename,100); imagedestroy($src); imagedestroy($tmp); // Script Ending, please check $thumbn = $sein . "th-" . $fale; cropImage(83, 60, "$target", "$ext", "$thumbn"); include("config.php"); $thumbnailss = "th-".$fale; mysql_query("INSERT INTO gallery (thumb_url, full_url) VALUES('$thumbnailss', '$fale' ) ") or die(mysql_error()); } } } ?> Hope i get a reply really quickly, thanks guys Link to comment https://forums.phpfreaks.com/topic/131704-solved-need-help-black-image/ Share on other sites More sharing options...
corbin Posted November 6, 2008 Share Posted November 6, 2008 $tmp=imagecreatetruecolor($newwidth,$newheight); $filename = $target; imagejpeg($tmp,$filename,100); Tmp is a blank image. Of course it's black. Link to comment https://forums.phpfreaks.com/topic/131704-solved-need-help-black-image/#findComment-684119 Share on other sites More sharing options...
dezkit Posted November 6, 2008 Author Share Posted November 6, 2008 Uhh, I didn't write the script, I got it off some website, can you tell me how to fix it so that the uploaded file is Tmp? Please, thanks! Link to comment https://forums.phpfreaks.com/topic/131704-solved-need-help-black-image/#findComment-684121 Share on other sites More sharing options...
corbin Posted November 6, 2008 Share Posted November 6, 2008 http://php.net/imagecopyresized So basically it would go something like: $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresized($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); Link to comment https://forums.phpfreaks.com/topic/131704-solved-need-help-black-image/#findComment-684125 Share on other sites More sharing options...
dezkit Posted November 6, 2008 Author Share Posted November 6, 2008 Thanks so much. <3 Link to comment https://forums.phpfreaks.com/topic/131704-solved-need-help-black-image/#findComment-684132 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.