I can't upload - here is the solution', change in config to be able to upload I can't upload - here is the solution', change in config to be able to upload
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

I can't upload - here is the solution', change in config to be able to upload

Started by foreverfan, December 25, 2005, 05:21:00 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

foreverfan

i had the following error while trying to upload a picture

The picture 'albums/userpics/briefaanvrouwinturkije~0.jpg' can't be inserted in the album

Unable to create thumbnail or reduced size image.



Warning: imagejpeg(): Unable to access albums/userpics/thumb_briefaanvrouwinturkije~0.jpg in /mysite.nl/httpdocs/gallery/cpg1.2.1_standalone/include/picmgmt.inc.php on line 187

Warning: imagejpeg(): Invalid filename 'albums/userpics/thumb_briefaanvrouwinturkije~0.jpg' in

mysite.nl/httpdocs/gallery/cpg1.2.1_standalone/include/picmgmt.inc.php on line 187

Warning: chmod(): Unable to access albums/userpics/thumb_briefaanvrouwinturkije~0.jpg in
/mysite.nlhttpdocs/gallery/cpg1.2.1_standalone/include/picmgmt.inc.php on line 193

Warning: chmod(): No such file or directory mysite.nll/httpdocs/gallery/cpg1.2.1_standalone/include/picmgmt.inc.php on line 193

Warning: getimagesize(): Unable to access albums/userpics/thumb_briefaanvrouwinturkije~0.jpg in mysitee.nl//httpdocs/gallery/cpg1.2.1_standalone/include/picmgmt.inc.php on line 195

Warning: getimagesize(albums/userpics/thumb_briefaanvrouwinturkije~0.jpg): failed to open stream: No such file or directory in /mysite.nl/httpdocs/gallery/cpg1.2.1_standalone/include/picmgmt.inc.php on line 195

The solution:

1. click on config

2. scroll down till you see
Pictures and thumbnails advanced settings 
Show private album Icon to unlogged user   Yes No 
Characters forbidden in filenames   
Accepted file extensions for uploaded pictures   
Method for resizing images 

3. Change
Method for resizing images
GD version 2
to GD version 1

4. Click on safe confirguration

Error is gone you will be able to upload

If there is still an error go and

OPEN  includes/picmgmt.inc

FIND
imagejpeg($dst_img, $dest_file, $CONFIG['jpeg_qual']);


REPLACE WITH
$fh=fopen($dest_file,'w');
fclose($fh);
imagejpeg($dst_img, $dest_file, $CONFIG['jpeg_qual']);

that error supposed is to fix a safe mode problem

If that doesnt work try if all your permissions are right. You need to chmod directories in cpg1.2.1_standalone/
(or where your copparmine gallery is located.
To chmode in WS_FTP 95 LE (program) i have to right click a directory or file and click on chmode there you can change permissions change them to what makes the gasllery work (try checking them all i think thats chmode 777).

http://www.download.com/3000-2160-10018456.html




kegobeer

Thanks for trying to help, but you should not switch to GD1.  Instead, you should just follow the directions in this sticky thread:

http://forum.coppermine-gallery.net/index.php?topic=23342.0
Do not send me a private message unless I ask for one.  Make your post public so everyone can benefit.

There are no stupid questions
But there are a LOT of inquisitive idiots

foreverfan

i did change with the fix, but unfortunately it didnt work for me. I guess i still have safe mod issues oh i see i have 1.2 might be why it doesnt work.


<?php
// ------------------------------------------------------------------------- //
// Coppermine Photo Gallery 1.2.1                                            //
// ------------------------------------------------------------------------- //
// Copyright (C) 2002,2003 Gregory DEMAR                                     //
// http://www.chezgreg.net/coppermine/                                       //
// ------------------------------------------------------------------------- //
// Updated by the Coppermine Dev Team                                        //
// (http://coppermine.sf.net/team/)                                          //
// see /docs/credits.html for details                                        //
// ------------------------------------------------------------------------- //
// This program is free software; you can redistribute it and/or modify      //
// it under the terms of the GNU General Public License as published by      //
// the Free Software Foundation; either version 2 of the License, or         //
// (at your option) any later version.                                       //
// ------------------------------------------------------------------------- //
// Add a picture to an album
function add_picture($aid, $filepath, $filename, $title = '', $caption = '', $keywords = '', $user1 = '', $user2 = '', $user3 = '', $user4 = '', $category = 0, $raw_ip = '', $hdr_ip = '')
{
    global $CONFIG, $ERROR, $USER_DATA, $PIC_NEED_APPROVAL;
    global $lang_errors;

    $image = $CONFIG['fullpath'] . $filepath . $filename;
    $normal = $CONFIG['fullpath'] . $filepath . $CONFIG['normal_pfx'] . $filename;
    $thumb = $CONFIG['fullpath'] . $filepath . $CONFIG['thumb_pfx'] . $filename;

    $imagesize = getimagesize($image);
    if (!file_exists($thumb))
        if (!resize_image($image, $thumb, $CONFIG['thumb_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use']))
            return false;

        if (max($imagesize[0], $imagesize[1]) > $CONFIG['picture_width'] && $CONFIG['make_intermediate'] && !file_exists($normal))
            if (!resize_image($image, $normal, $CONFIG['picture_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use']))
                return false;

            $image_filesize = filesize($image);
            $total_filesize = $image_filesize + (file_exists($normal) ? filesize($normal) : 0) + filesize($thumb);
            // Test if disk quota exceeded
            if (!GALLERY_ADMIN_MODE && $USER_DATA['group_quota']) {
                $result = db_query("SELECT sum(total_filesize) FROM {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']} WHERE  {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND category = '" . (FIRST_USER_CAT + USER_ID) . "'");
                $record = mysql_fetch_array($result);
                $total_space_used = $record[0];
                mysql_free_result($result);

                if ($total_space_used + $total_filesize > $USER_DATA['group_quota'] << 10) {
                    @unlink($image);
                    @unlink($normal);
                    @unlink($thumb);
                    $msg = strtr($lang_errors['quota_exceeded'], array('[quota]' => ($USER_DATA['group_quota']),
                            '[space]' => ($total_space_used >> 10)));

                    cpg_die(ERROR, $msg, __FILE__, __LINE__);
                }
            }
            // Test if picture requires approval
            if (GALLERY_ADMIN_MODE) {
                $approved = 'YES';
            } elseif (!$USER_DATA['priv_upl_need_approval'] && $category == FIRST_USER_CAT + USER_ID) {
                $approved = 'YES';
            } elseif (!$USER_DATA['pub_upl_need_approval']) {
                $approved = 'YES';
            } else {
                $approved = 'NO';
            }
            $PIC_NEED_APPROVAL = ($approved == 'NO');
            // User ID is not recorded when in admin mode (ie. for batch uploads)
            $user_id = GALLERY_ADMIN_MODE ? 0 : USER_ID;
         $username=$USER_DATA['user_name'] ;
            $query = "INSERT INTO {$CONFIG['TABLE_PICTURES']} (pid, aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, owner_name, title, caption, keywords, approved, user1, user2, user3, user4, pic_raw_ip, pic_hdr_ip) VALUES ('', '$aid', '" . addslashes($filepath) . "', '" . addslashes($filename) . "', '$image_filesize', '$total_filesize', '{$imagesize[0]}', '{$imagesize[1]}', '" . time() . "', '$user_id', '$username','$title', '$caption', '$keywords', '$approved', '$user1', '$user2', '$user3', '$user4', '$raw_ip', '$hdr_ip')";
            $result = db_query($query);

            return $result;
        }

        define("GIS_GIF", 1);
        define("GIS_JPG", 2);
        define("GIS_PNG", 3);

        /**
         * resize_image()
         *
         * Create a file containing a resized image
         *
         * @param  $src_file the source file
         * @param  $dest_file the destination file
         * @param  $new_size the size of the square within which the new image must fit
         * @param  $method the method used for image resizing
         * @return 'true' in case of success
         */
        function resize_image($src_file, $dest_file, $new_size, $method, $thumb_use)
        {
            global $CONFIG, $ERROR;
            global $lang_errors;

            $imginfo = getimagesize($src_file);
            if ($imginfo == null)
                return false;
            // GD can only handle JPG & PNG images
            if ($imginfo[2] != GIS_JPG && $imginfo[2] != GIS_PNG && ($method == 'gd1' || $method == 'gd2')) {
                $ERROR = $lang_errors['gd_file_type_err'];
                return false;
            }
            // height/width
            $srcWidth = $imginfo[0];
            $srcHeight = $imginfo[1];
            if ($thumb_use == 'ht') {
                $ratio = $srcHeight / $new_size;
            } elseif ($thumb_use == 'wd') {
                $ratio = $srcWidth / $new_size;
            } else {
                $ratio = max($srcWidth, $srcHeight) / $new_size;
            }
            $ratio = max($ratio, 1.0);
            $destWidth = (int)($srcWidth / $ratio);
            $destHeight = (int)($srcHeight / $ratio);
            // Method for thumbnails creation
            switch ($method) {
                case "im" :
                    if (preg_match("#[A-Z]:|\\\\#Ai", __FILE__)) {
                        // get the basedir, remove '/include'
                        $cur_dir = substr(dirname(__FILE__), 0, -8);
                        $src_file = '"' . $cur_dir . '\\' . strtr($src_file, '/', '\\') . '"';
                        $im_dest_file = str_replace('%', '%%', ('"' . $cur_dir . '\\' . strtr($dest_file, '/', '\\') . '"'));
                    } else {
                        $src_file = escapeshellarg($src_file);
                        $im_dest_file = str_replace('%', '%%', escapeshellarg($dest_file));
                    }

                    $output = array();
                    $cmd = "{$CONFIG['impath']}convert -quality {$CONFIG['jpeg_qual']} {$CONFIG['im_options']} -geometry {$destWidth}x{$destHeight} $src_file $im_dest_file";
                    exec ($cmd, $output, $retval);

                    if ($retval) {
                        $ERROR = "Error executing ImageMagick - Return value: $retval";
                        if ($CONFIG['debug_mode']) {
                            // Re-execute the command with the backtit operator in order to get all outputs
                            // will not work is safe mode is enabled
                            $output = `$cmd 2>&1`;
                            $ERROR .= "<br /><br /><div align=\"left\">Cmd line : <br /><font size=\"2\">" . nl2br(htmlspecialchars($cmd)) . "</font></div>";
                            $ERROR .= "<br /><br /><div align=\"left\">The convert program said:<br /><font size=\"2\">";
                            $ERROR .= nl2br(htmlspecialchars($output));
                            $ERROR .= "</font></div>";
                        }
                        @unlink($dest_file);
                        return false;
                    }
                    break;

                case "gd1" :
                    if (!function_exists('imagecreatefromjpeg')) {
                        cpg_die(CRITICAL_ERROR, 'PHP running on your server does not support the GD image library, check with your webhost if ImageMagick is installed', __FILE__, __LINE__);
                    }
                    if ($imginfo[2] == GIS_JPG)
                        $src_img = imagecreatefromjpeg($src_file);
                    else
                        $src_img = imagecreatefrompng($src_file);
                    if (!$src_img) {
                        $ERROR = $lang_errors['invalid_image'];
                        return false;
                    }
                    $dst_img = imagecreate($destWidth, $destHeight);
                    imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $destWidth, (int)$destHeight, $srcWidth, $srcHeight);
                    $fh=fopen($dest_file,'w');
fclose($fh);
imagejpeg($dst_img, $dest_file, $CONFIG['jpeg_qual']);
               imagedestroy($src_img);
                    imagedestroy($dst_img);
                    break;

                case "gd2" :
                    if (!function_exists('imagecreatefromjpeg')) {
                        cpg_die(CRITICAL_ERROR, 'PHP running on your server does not support the GD image library, check with your webhost if ImageMagick is installed', __FILE__, __LINE__);
                    }
                    if (!function_exists('imagecreatetruecolor')) {
                        cpg_die(CRITICAL_ERROR, 'PHP running on your server does not support GD version 2.x, please switch to GD version 1.x on the config page', __FILE__, __LINE__);
                    }
                    if ($imginfo[2] == GIS_JPG)
                        $src_img = imagecreatefromjpeg($src_file);
                    else
                        $src_img = imagecreatefrompng($src_file);
                    if (!$src_img) {
                        $ERROR = $lang_errors['invalid_image'];
                        return false;
                    }
                    $dst_img = imagecreatetruecolor($destWidth, $destHeight);
                    imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $destWidth, (int)$destHeight, $srcWidth, $srcHeight);
                    imagejpeg($dst_img, $dest_file, $CONFIG['jpeg_qual']);
                    imagedestroy($src_img);
                    imagedestroy($dst_img);
                    break;
            }
            // Set mode of uploaded picture
            chmod($dest_file, octdec($CONFIG['default_file_mode']));
            // We check that the image is valid
            $imginfo = getimagesize($dest_file);
            if ($imginfo == null) {
                $ERROR = $lang_errors['resize_failed'];
                @unlink($dest_file);
                return false;
            } else {
                return true;
            }
        }

        ?>

Azrayen

Well, let's say that Coppermine's last version is now 1.4.2 (stable).
Why don't you just upgrade ? Lots of bugs and security issues've been fixed since 1.2 !

Regards,
Azrayen'

kegobeer

Do not send me a private message unless I ask for one.  Make your post public so everyone can benefit.

There are no stupid questions
But there are a LOT of inquisitive idiots

foreverfan

i upgraded to 1.4.2. yesterday. I even bridged with mambo and that worked yesterday, Today i didnt see my upload function anymore when loging in as an admin thatn ideced to undo the bridge and couldnt login anymore. Then with help of searching this forum i managed to get in to the ""groups"to change the permissions. and changed the file again so that noone else can get into the groups
with the bridged version i srtill have problems unfortunately i think im not able to make mambo integration work for a longer period of time righ now