Jump to content

dynamic images


FeRo

Recommended Posts

Hi, I've been sitting on this problem for days now...I've got two files:index.php:

<html>    <head>    </head>    <body>  <img src='getImage.php' />    </body></html>

getImage.php:

<?php$img = imagecreatefromjpeg("/datei.jpg");  header("Content-Type: image/jpeg");  imagejpeg($img);  imagedestroy($img);?>

Those 2 php files and the image are all in the root directory. I think the code is correct and using firebug I don't get an error, but still there is only an empty image icon displayed...I made both php files executable and the imagefile writable just to be sure, but still, no change.Help is reaaaally appreciated!Thanks

Link to comment
Share on other sites

I think the file doesn't exist. This path "/datei.jpg" looks for the file at the system root, not the website's root. If the image is in the same directory as the PHP file then just forget the slash and put "datei.jpg" On a windows computer, your website root would be something like C:/www/. On linux the website root is probably something like /usr/something/website/www/. Putting a / will bring you to the system root which is just C:/ (windows) or / for linux

Link to comment
Share on other sites

PHP is not accessing the root of your website, it's trying to get a file in the root of the computer that your website is hosted on which is a different directory. Use relative file paths.

  • Like 1
Link to comment
Share on other sites

PHP is not accessing the root of your website, it's trying to get a file in the root of the computer that your website is hosted on which is a different directory. Use relative file paths.
but how am I supposed to do that? I mean the two files are in the same directory...
Link to comment
Share on other sites

Alright I got it... The image size was too big... It's working now... And it took me hours -.-And I used the $_SERVER['DOCUMENT_ROOT'] variable, that helped too! Thank you! :)

Edited by FeRo
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...