Hey guys,
For some reason I cant get this to work... The original problem was: only jpeg images would upload and display.
This is the image code I am working with.
Any help would be greatly appreciated.
Thanks!
if(isset($_FILES["photo1"]["tmp_name"])&& $_FILES["photo1"]["tmp_name"]!="")
{
$file_temp = $_FILES['photo1']['tmp_name'];
$original_file_name = $_FILES['photo1']['name'];
$new_file_name = time().$original_file_name;
$filepath = "../temp_files/".$new_file_name;
move_uploaded_file( $file_temp , $filepath );
// Creating Full Image
$thumbnail = "FULL".$new_file_name;
$thumbnailpath = "../temp_files/".$thumbnail;
$imageBoxSize = 207;
list($fileWidth,$fileHeight, $image_type)=getimagesize($filepath);
if($fileHeight > $fileWidth)
{$unit = $fileWidth/$fileHeight; $width = $imageBoxSize * $unit; $height = $imageBoxSize;}
else
{$unit = $fileHeight/$fileWidth; $height = $imageBoxSize * $unit; $width = $imageBoxSize;}
switch ($image_type)
{
case 1: $src = imagecreatefromgif($filepath); break;
case 2: $src = imagecreatefromjpeg($filepath); break;
case 3: $src = imagecreatefrompng($filepath); break;
default: trigger_error('Unsupported filetype!', E_USER_WARNING); break;
}
$tmp = imagecreatetruecolor($width,$height);
imagecopyresampled($tmp,$src,0,0,0,0,$width,$height,$fileWidth,$fileHeight);
if(imagejpeg($tmp,$thumbnailpath,100));
//Creating Thumbnail
$thumbnail = "TN".$new_file_name;
$thumbnailpath = "../temp_files/".$thumbnail;
$imageBoxSize = 50;
list($fileWidth,$fileHeight)=getimagesize($filepath);
if($fileHeight > $fileWidth)
{$unit = $fileWidth/$fileHeight; $width = $imageBoxSize * $unit; $height = $imageBoxSize;}
else
{$unit = $fileHeight/$fileWidth; $height = $imageBoxSize * $unit; $width = $imageBoxSize;}
$src = imagecreatefromjpeg($filepath);
$tmp = imagecreatetruecolor($width,$height);
imagecopyresampled($tmp,$src,0,0,0,0,$width,$height,$fileWidth,$fileHeight);
if(imagejpeg($tmp,$thumbnailpath,100));
//Creating MainPage Thumbnail
$thumbnail = "MAIN".$new_file_name;
$thumbnailpath = "../temp_files/".$thumbnail;
$imageBoxSize = 87;
list($fileWidth,$fileHeight)=getimagesize($filepath);
if($fileHeight > $fileWidth)
{$unit = $fileWidth/$fileHeight; $width = $imageBoxSize * $unit; $height = $imageBoxSize;}
else
{$unit = $fileHeight/$fileWidth; $height = $imageBoxSize * $unit; $width = $imageBoxSize;}
$src = imagecreatefromjpeg($filepath);
$tmp = imagecreatetruecolor($width,$height);
imagecopyresampled($tmp,$src,0,0,0,0,$width,$height,$fileWidth,$fileHeight);
if(imagejpeg($tmp,$thumbnailpath,100));
//Deleting Original File
unlink($filepath);
$_SESSION['photo1'] = $new_file_name;