Zubrag.com
September 25, 2018, 11:16:12 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Custom error image at thumbs creator  (Read 18495 times)
danny
Newbie
*
Posts: 3


« on: March 13, 2007, 01:36:02 PM »

Thank you very much for your wonderful script! Do you know how can I replace an error for a custom image?

For example if the image is not specified or found.

if (isset($_REQUEST['src'])) {
  $from_name = urldecode($_REQUEST['src']);
}
else {
  die("Source file name must be specified.");
}


Thank you =)

Logged
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #1 on: March 13, 2007, 01:47:01 PM »

Do you mean show custom image instead of error message?

Replace
die("Source file name must be specified.");

with
header("Content-type: image/gif");
readfile('/here/path/to/your/custom/image.gif');
die();

This is for custom error image of GIF type.

If you custom error image is JPG then replace image/gif with image/jpeg.
If you custom error image is PNG then replace image/gif with image/png.
Logged
danny
Newbie
*
Posts: 3


« Reply #2 on: March 13, 2007, 02:53:12 PM »

Hi Zubrag, thank you for your reply. yes, I want it show an image when an incomplete action is typed: http://domain.com/pics/thumb.php?src=    but I get this error...

Warning: getimagesize(): Read error! in /home/host/public_html/pics/thumb.php on line x
Image type not supported


My readfile is the same $images_folder


if (isset($_REQUEST['src'])) {
  $from_name = urldecode($_REQUEST['src']);
}
else {
  header("Content-type:image/jpg");
  readfile('/home/host/public_html/pics/image.jpg/');
  die();
}

Best Regards   =)
Logged
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #3 on: March 14, 2007, 03:52:19 AM »

Changed code. Note: also removed / after the image name.

if (isset($_REQUEST['src']) && trim($_REQUEST['src']) != '') {
  $from_name = urldecode($_REQUEST['src']);
}
else {
  header("Content-type:image/jpg");
  readfile('/home/host/public_html/pics/image.jpg');
  die();
}
Logged
danny
Newbie
*
Posts: 3


« Reply #4 on: March 14, 2007, 10:30:01 AM »

Hi !
I made the changes but I got this error:

Parse error: syntax error, unexpected ')' in /home/host/public_html/pics/thumb.php on line 68

if (isset($_REQUEST['src']) && trim($_REQUEST['src']) !=) {
  $from_name = urldecode($_REQUEST['src']);
}

Thanks !  Undecided
Logged
zubrag
Administrator
Hero Member
*****
Posts: 788


WWW
« Reply #5 on: March 14, 2007, 11:32:20 AM »

You missed two single quotes before closing bracket. It should be
if (isset($_REQUEST['src']) && trim($_REQUEST['src']) != '') {
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC