andy's php projects
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Script and site usage:
All of the scripts on this site are provided free for non-commerical, personal or non-profit use. If you find these scripts useful to you, appreciate the free support, or are just an all round nice person, then why not donate a little dosh? If you wish to use any of these in a commercial system, please refer to the payment plan.


Could not save the output file

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> Crop Canvas
View previous topic :: View next topic  
Author Message
blenger
Newbie


Joined: 22 Nov 2004
Posts: 4

PostPosted: Mon Nov 22, 2004 7:33 am    Post subject: Could not save the output file Reply with quote

Hi there,

I?m having problems saving the output image, and i can?t figure out what?s going on, i can crop and show the image with the "$ci->showImage('jpg', 100);" function, but when i try to save it with "saveImage" it returns me this.

----------------------------------------------
Warning: imagejpeg(): Unable to open '/var/www/html/bramidia.com.br/crop2/mypicture.jpg' for writing in var/www/html/bramidia.com.br/crop2/class.cropcanvas.php on line 172

Error in function saveImage:</strong> Could not save the output file '/var/www/html/bramidia.com.br/crop2/mypicture.jpg' as a jpeg
----------------------------------------------

I even tried using realpath, this is my code:

----------------------------------------------
require_once 'class.cropinterface.php';
$ci = new cropInterface(true);

if ($_GET['file'])
{
$ci->loadImage($_GET['file']);
$ci->cropToDimensions($_GET['sx'], $_GET['sy'], $_GET['ex'], $_GET['ey']);
//header('Content-type: image/jpeg');
//$ci->showImage('jpg', 100);
$test = realpath("mypicture.jpg");
$ci->saveImage($test, 80);

exit;
}
----------------------------------------------
I?m sure the folder have the writing permissions and everythink, i think i?m missing something...
I really think this is a kickass code, and i hope i can get it working!

Thanks for the help.
Back to top
View user's profile Send private message
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Mon Nov 22, 2004 11:21 am    Post subject: Reply with quote

Hi blenger, and welcome to the board!

I know you said you checked the permissions, but it really does sound like that is the problem. Permissions or perhaps the path is incorrect? Are you sure this is the path?

/var/www/html/bramidia.com.br/crop2/

If you can log in via the shell and do an 'ls -l' in this path; '/var/www/html/bramidia.com.br/', what does the permissions show as for 'crop2'?

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
blenger
Newbie


Joined: 22 Nov 2004
Posts: 4

PostPosted: Mon Nov 22, 2004 12:13 pm    Post subject: Permissions Reply with quote

I can?t check this permissions from here, i can only test this script online, but my server?s admin told me that i have writing permissions for all folders.

As for the path, i don?t think that?s the problem, since i?m trying to write this file in the same dir as the .php files, and when i tried that with realpath it really seems to be right.

Can you imagine anything else that could be wrong?

By the way, thanks for your help, and sorry if my english isn?t very good, i?m from Brazil.
Back to top
View user's profile Send private message
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Fri Nov 26, 2004 4:38 am    Post subject: Reply with quote

Save this code to a file and upload it to the same place you're trying to save the images to. Then view the file in a browser. It should hopefully tell you the permissions of the directory:

PHP:
<?php

    $perms 
fileperms(dirname(__FILE__));
    if (
$perms === false) {
        echo 
'Cannot get permissions of the directory';
    } else {
        echo 
dirname(__FILE__), ' = 'substr(sprintf('%o'$perms), -3);
    }

?>


Also; don't apologise about your english! I think it's very good, and hell of a lot better than I can speak a foreign language! Kudos to you for being multi-lingual. Smile

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
blenger
Newbie


Joined: 22 Nov 2004
Posts: 4

PostPosted: Fri Nov 26, 2004 6:40 am    Post subject: Permissions Reply with quote

Well, i?m new at linux so i don?t know what that means, but this is what the script shows:

----------------------------------------
/var/www/html/bramidia.com.br/crop2 = 755
----------------------------------------

Is that right?
Back to top
View user's profile Send private message
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Fri Nov 26, 2004 7:51 am    Post subject: Reply with quote

Hi,

That's exactly what the script is meant to output. That tells you that the crop2 folder have the permissions '-rwxr-xr-x', which means that the 'user' can write to it, but the 'group' and 'others' cannot. This is okay if, and only if, PHP is running under your username (such as it might be set up to do through the CGI module, rather than the apache module).

You can test PHP writing a file to the directory with this code:

PHP:
<?php

$filename 
'testfile.tmp';
if (!
$fp fopen($filename'w')) { 
    echo 
"Cannot open file ($filename)"
} else {
    
fwrite($fp"I can write to this file.\n");
    
fclose($fp);
}

?>


If you get an error or no file exists after you've run that code, then PHP cannot write to that directory. You could ask your server admin to alter that so PHP can write to the directory, or you could tweak it yourself with the 'chmod' command (if you have shell access), or the 'chmod()' function in PHP: http://www.php.net/chmod/

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
blenger
Newbie


Joined: 22 Nov 2004
Posts: 4

PostPosted: Fri Nov 26, 2004 10:24 am    Post subject: Permissions Reply with quote

Ahhhhhh it?s alive!!!

You were right, my server?s admin gave me restricted writing permissions to that folder, i asked him to open all permissions and now it works!

Thank you very much for the help, this script will be very usefull to me.

[]'s
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> Crop Canvas All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group