Jump to content

[SOLVED] need help: black image


dezkit

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.