jfee1212 Posted June 26, 2006 Share Posted June 26, 2006 I have made an upload script, and do the requirements of uploadin, the upload folder has write access.The problem is, I want that folder to be somewhere where it can only be uploaded to by my server.Also, (this script regards images) I need to be able to include the uploaded images in a page.I tried using relative paths.... eg[code]<img src="../../uploads/imagefilename.jpg" />[code] but that doesnt work.Any help? do I need to do an fopen on the file? Quote Link to comment https://forums.phpfreaks.com/topic/12972-web-inaccessible-folder-how-to-access/ Share on other sites More sharing options...
redarrow Posted June 26, 2006 Share Posted June 26, 2006 are you using windows?does the folder exist uploads?are you using a database?post the script and form okif the folder uploads exist and the imagefilename exist thiswill work on windows.the uploads folder has to be in the same directoryas the php script with the below example.[code]<img src="uploads/imagefilename.jpg" >[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12972-web-inaccessible-folder-how-to-access/#findComment-49866 Share on other sites More sharing options...
jfee1212 Posted June 27, 2006 Author Share Posted June 27, 2006 I am developing in linux and the server is also linux.The upload script works perfectly fine (after one slight modification), but I am not sure how to access the image.I tried this:[code]echo "<div align='center'><img align='center' src='../../uploads/uploads/$image_path' /></div>";[/code]where $image_path is the dynamically generated image path. The outputted code in the page is:[code]<img align='center' src='../../uploads/uploads/30.jpg' />[/code]Which looks like it should work, however it does not. (that is the right directory by the way)any help? Quote Link to comment https://forums.phpfreaks.com/topic/12972-web-inaccessible-folder-how-to-access/#findComment-49875 Share on other sites More sharing options...
redarrow Posted June 27, 2006 Share Posted June 27, 2006 [code]<img align='center' src='http://www.whatever.com/uploads/30.jpg' />[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12972-web-inaccessible-folder-how-to-access/#findComment-49885 Share on other sites More sharing options...
jfee1212 Posted June 27, 2006 Author Share Posted June 27, 2006 like I said, it is not in public_html so people can't use their own scripts to upload unwanted files to that folder.../.. goes above the www.site.com, but it is not displaying the picture Quote Link to comment https://forums.phpfreaks.com/topic/12972-web-inaccessible-folder-how-to-access/#findComment-49886 Share on other sites More sharing options...
dptr1988 Posted June 27, 2006 Share Posted June 27, 2006 I don't know what server you are using, but on apache you can't 'go above' the site by using relative paths. You could try making a PHP script that would read the image file from the protected directory and send it to the browser. Maybe this code can explain better:[code]<IMG src="get_img.php?image=30.jpg">[/code] get_img.php[code]<?php$filename = $_GET['image'];$path = '../../uploads/';// send the proper headers for the image with header();readfile($path.$filename);?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12972-web-inaccessible-folder-how-to-access/#findComment-49889 Share on other sites More sharing options...
jfee1212 Posted June 27, 2006 Author Share Posted June 27, 2006 the problem with that is that I am accessing the image inline with another page.[a href=\"http://www.jafsitedesign.com/collegeartstore\" target=\"_blank\"]http://www.jafsitedesign.com/collegeartstore[/a]the uploads file is ../../uploads/uploads relative to collegeartstore Quote Link to comment https://forums.phpfreaks.com/topic/12972-web-inaccessible-folder-how-to-access/#findComment-49896 Share on other sites More sharing options...
jfee1212 Posted June 27, 2006 Author Share Posted June 27, 2006 bump... any help? Quote Link to comment https://forums.phpfreaks.com/topic/12972-web-inaccessible-folder-how-to-access/#findComment-50129 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.