Jump to content

Recommended Posts

Hi,

I'm using a simple image resize php script to resize images. It was working fine but has now stopped working but can't figure out why! The script is:

[code]$src = imagecreatefromjpeg($image);
    $width = imagesx($src);
    $height = imagesy($src);
    $x = $w; $y = $h;
    $dst = imagecreatetruecolor($x,$y);
    imagecopyresampled($dst,$src,0,0,0,0,$x,$y,$width,$height);    
    header('Content-Type: image/png');
    imagepng($dst);[/code]

Its saved as scale_img.php and called from another page like so:

[code]<img src="scale_img.php?image=images/horses.jpg&w=100&h=100" />[/code]

Is there anything wrong with the php code? It looks ok to me. Could changed php settings on the server ( i use third party) affect it working or not? Other php/mysql scripts work fine
What do mean by "not working"?

Looking at your code, it looks like you're assuming that register_globals is enabled. If your host set it to disabled, that would explain the problem.

If this is the problem -- comfirm it with your host, then the fix is simple, just change "$image" to $_GET['image']
[code]<?php
$src = imagecreatefromjpeg($_GET['image']);
?>[/code]

If you host changed register_globals from enabled to disabled without telling you, then if I were you, I would complain loudly.

Ken
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.