Jump to content

Recommended Posts

Hello,

 

I have this upload script that creates thumbnails. But i keep getting the following errors

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, $image, 0, 0, 0, 0, $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');
}



}
?>

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/191472-thumbnails-of-a-file/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.