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.


Linking to another page after showing the cropped image

 
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
Ham
Newbie


Joined: 24 Feb 2005
Posts: 4

PostPosted: Fri Feb 25, 2005 2:09 pm    Post subject: Linking to another page after showing the cropped image Reply with quote

I'm trying to provide a link to the user to go back to the previous page, or automatically refresh the page after it shows the cropped image. Where do I put the code to do this? I tried to put the href link after the saveImage call put it doesn't show the link.

I have:

require_once 'class.cropinterface.php';
$ci = new cropInterface();
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);

$ci->saveImage("$path", 100);


} else {
$ci->loadInterface("originalImages/$image");
$ci->loadJavaScript();
}
Back to top
View user's profile Send private message
Ham
Newbie


Joined: 24 Feb 2005
Posts: 4

PostPosted: Fri Feb 25, 2005 2:31 pm    Post subject: Reply with quote

Also, I can't seem to get away without calling showImage (says the image ..... cannot be displayed because it contains errors) if I try commenting it out

I like the cropping to be done and the page to be redirected immediately after I click the crop button.

Thanks for all 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 Feb 28, 2005 6:06 am    Post subject: Re: Linking to another page after showing the cropped image Reply with quote

Hi Ham, and welcome to the board!

To address your second post first; if you didn't remove the 'header(...)' line as well as the saveImage call, then the web sevrer is telling your browser that it should expect a jpg image. The browser then doesn't get the expected binary data, so says the image cannot be displayed. Taking out the saveImage AND the header lines will enable you to do what you want.

To redirect a user you could simply execute a different header() call, this time with a 'Location' parameter, giving the url you want to take them to.

For example:

PHP:
<?php

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

if (
$_GET['file']) {
    
$ci->loadImage($_GET['file']);
    
$ci->cropToDimensions($_GET['sx'], $_GET['sy'], $_GET['ex'], $_GET['ey']);
    
$ci->saveImage($path100);
    
header('Location: image_cropped.php');
} else {
    
$ci->loadInterface("originalImages/$image");
    
$ci->loadJavaScript();
}

?>


Make sure you haven't sent any text to the browser already before sending a Location header else you'll just get complained at. (You could circumvent this by using output buffering - ob_* functions in php.)

'image_cropped.php' would obviously be replaced with whatever url you want to send them to (even a page that has query string parameters is okay).

HTH,

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
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