Nodral Posted August 23, 2011 Share Posted August 23, 2011 Hi I've a directory structure which is root/web/dir1/dir2/dir3/sitefiles.php and root/tmp/tempfile.jpg Within sitefiles.php I have greated an image file and saved it successfully as tempfile.jpg. However, when I then try to call it back and include it in an HTML output from another script within dir3, I get an error saying it can't be found. I have used exactly the same file path and I'm completely stumped as to why it's falling over. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/245487-filepaths-not-working/ Share on other sites More sharing options...
trq Posted August 23, 2011 Share Posted August 23, 2011 Can we see some relevant code? Quote Link to comment https://forums.phpfreaks.com/topic/245487-filepaths-not-working/#findComment-1260887 Share on other sites More sharing options...
Nodral Posted August 23, 2011 Author Share Posted August 23, 2011 Create file - This works fine $filename="/home/httpd/vhosts/xxxxxx.co.uk/tmp/line_all".$identify . $_SESSION['USERID'] . ".jpg"; include"graph.php"; graph.php creates the jpg and saves to $filename. <table id="line"><tr><td id="border"></td><td id="top">It is recommended that you complete the questionnaire periodically to monitor if your Learning Style is changing over time.<br><br> The chart below shows the development of Learning Styles over a period of time and should help you to adjust to any changes you have experienced</td><td id="border"></td></tr><tr><td id="border"></td><td id="bottom"><img src="<?php echo "/home/httpd/vhosts/xxxxxx.co.uk/tmp/line_all".$identify . $_SESSION['USERID'] . ".jpg"; ?>" width="500" height="500"></td><td id="border"></td></tr><tr></table></p> This is the output code, which cannot find the image flie which has saved successfully. The file permissions get set to 777 in graph.php Quote Link to comment https://forums.phpfreaks.com/topic/245487-filepaths-not-working/#findComment-1260891 Share on other sites More sharing options...
trq Posted August 23, 2011 Share Posted August 23, 2011 /home/httpd/vhosts is not accessible by a client (browser). You need to use a path starting at your document root. Quote Link to comment https://forums.phpfreaks.com/topic/245487-filepaths-not-working/#findComment-1260892 Share on other sites More sharing options...
Nodral Posted August 23, 2011 Author Share Posted August 23, 2011 The tmp folder is at a higher level than my document root. Is there a way I can call an image file from there using php prior to sending to the browser? Quote Link to comment https://forums.phpfreaks.com/topic/245487-filepaths-not-working/#findComment-1260893 Share on other sites More sharing options...
trq Posted August 23, 2011 Share Posted August 23, 2011 You would need to write a php script to get the file and output it to the browser Your image tag would end up looking like: <img src="image.php?f=imagename" /> You should find an example of such a script in the readfile man page. Quote Link to comment https://forums.phpfreaks.com/topic/245487-filepaths-not-working/#findComment-1260895 Share on other sites More sharing options...
Nodral Posted August 23, 2011 Author Share Posted August 23, 2011 Cheers for that I've read the information in the manual, but this describes how to prepare to download a file, rather than insert into an HTML page. I'm not the best with headers etc. Can someone help me with how to use the readfile() function. As in previous posts, I have some image files I have created and saved which I need to load into the page. Quote Link to comment https://forums.phpfreaks.com/topic/245487-filepaths-not-working/#findComment-1260904 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.