Author Topic: Thumbnails of a file  (Read 80 times)

0 Members and 1 Guest are viewing this topic.

Offline adam291086Topic starter

  • Devotee
    • View Profile
Thumbnails of a file
« on: February 09, 2010, 06:11:26 AM »
Hello,

I have this upload script that creates thumbnails. But i keep getting the following errors
Quote
Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /home/rubberduckiee/webapps/editor/Xinha/plugins/ExtendedFileManager/external_upload.php on line 107

Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/rubberduckiee/webapps/editor/Xinha/plugins/ExtendedFileManager/external_upload.php on line 109

Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/rubberduckiee/webapps/editor/Xinha/plugins/ExtendedFileManager/external_upload.php on line 115

Warning: Cannot modify header information - headers already sent by (output started at /home/rubberduckiee/webapps/editor/Xinha/plugins/ExtendedFileManager/external_upload.php:107) in /home/rubberduckiee/webapps/editor/Xinha/plugins/ExtendedFileManager/external_upload.php on line 122


here is the full script
<?php
require_once 'Classes/ExtendedFileManager.php';
require_once(
'config.inc.php');

$file $_FILES['upload'];
$error 0;
$size 0.45;



if(!empty(
$file))
{

$dir $_POST['dir'];
$target "/home/rubberduckiee/webapps/editor/Xinha/plugins/ExtendedFileManager/files".$dir."/".basename($file['name']) ;
$file_extension strtolower(substr(strrchr($file['name'], "."), 1));
$max_size $IMConfig['max_filesize_kb_image'];



//This is our limit file type condition
if(!in_array($file_extension$IMConfig['allowed_image_extensions']))
    {
        
$message "Please make sure you are uploading the correct file type";
        if(
is_file($file['tmp_name']))
        {
            
unlink($file['tmp_name']);
        }
        
$error 1;

    }

else if (
file_exists($target))
    {
        
$error 1;
        
$message "File alread exists";
         if(
is_file($file['tmp_name']))
        {
            
unlink($file['tmp_name']);
            
        }
    }


else if(!
is_file($file['tmp_name']))
    {
        
$message "Pease make sure you are uploading a file";
        
$error 1;
        if(
is_file($file['tmp_name']))
        {
            
unlink($file['tmp_name']);
            
$error 1;
        }

    }

else if(!
is_uploaded_file($file['tmp_name']))
    {
        
$message "Pease make sure you are uploading a file";
        
$error 1;
        if(
is_file($file['tmp_name']))
        {
            
unlink($file['tmp_name']);
        }
    }

else if(
$file['size']>($max_size*1024))
	
	
{
	
	
	
$message "File size is too large. Max size is 10Mb";
            
$error 1;
            if(
is_file($file['tmp_name']))
            {
                
unlink($file['tmp_name']);
            }
	
	
}

if (
$error == 1)
{
    
header('Location: http://rubberduckiee.webfactional.com/file/error_upload/'.$message);
}
else if (
in_array($file_extension, array("jpg","bmp","jpeg")))
{
    if (
move_uploaded_file($file['tmp_name'], $target))
    {
        
// Get new dimensions
        
list($width_orig$height_orig) = getimagesize($target);

        if (
$width_orig $IMConfig['thumbnail_width'])
        {
            
$width $width_orig $size;
        }
        else
        {
            
$width $width_orig;
        }
        if (
$height_orig $IMConfig['thumbnail_height'])
        {
            
$height $height $size;
        }
        else
        {
            
$height $height_orig;
            
        }

        
// Resample
        
$image_p imagecreatetruecolor($width$height);
        
$image   imagecreatefromjpeg($target);
        
imagecopyresampled($image_p$image0000$width$height$width_orig$height_orig);

        
$pathToThumbs "/home/rubberduckiee/webapps/editor/Xinha/plugins/ExtendedFileManager/files".$dir."/thumbnail/";
        
$fname "thumbnail_".$file['name'];


        if (
imagejpeg($image_p"{$pathToThumbs}{$fname}"))
        {
            
header('Location: http://rubberduckiee.webfactional.com/file/browse');
        }
        else
        {
            
$message "file not uploaded";
            
header('Location: http://rubberduckiee.webfactional.com/file/error_upload/'.$message);
            
unlink($target);
            
        }
    }
}
else
{
    
move_uploaded_file($file['tmp_name'], $target);
    
header('Location: http://rubberduckiee.webfactional.com/file/browse');
}



}
?>





Hate is a strong word. But i really don't like you.

Offline MadTechie

  • PHPFreaks Recommended
  • Freak!
  • *
  • Gender: Male
  • I try to F1
    • View Profile
Re: Thumbnails of a file
« Reply #1 on: February 09, 2010, 08:28:55 AM »
Quote
Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /home/rubberduckiee/webapps/editor/Xinha/plugins/ExtendedFileManager/external_upload.php on line 107


Without me having to look though all the code, just echo out the $width & $height.
Computers are good at following instructions, but not at reading your mind.
After all, why would you insert your penis into a hole for no reason whatsoever?

I dunno about that.  A regular expression has a 0% chance of touching my penis.

the code is professionally made up but not working

Remember to Click Solved, how to ask questions - the smart way

PHP Freaks Forums

« on: »

Tired of these ads? Purchase a supporter subscription to get rid of them.