FeRo Posted April 15, 2013 Share Posted April 15, 2013 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 More sharing options...
Ingolme Posted April 15, 2013 Share Posted April 15, 2013 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 More sharing options...
FeRo Posted April 15, 2013 Author Share Posted April 15, 2013 The problem is, when I leave the slash I get a 500 internal error(in firebug) and I don't know why, because I obviously have the image in my root website folder. Link to comment Share on other sites More sharing options...
Ingolme Posted April 15, 2013 Share Posted April 15, 2013 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. 1 Link to comment Share on other sites More sharing options...
justsomeguy Posted April 15, 2013 Share Posted April 15, 2013 It would also be a good idea to pull up your getImage page directly to see if it is outputting an error message. You may need to enable error messages in the code. Link to comment Share on other sites More sharing options...
FeRo Posted April 15, 2013 Author Share Posted April 15, 2013 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 More sharing options...
FeRo Posted April 15, 2013 Author Share Posted April 15, 2013 (edited) 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 April 15, 2013 by FeRo Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now