Jump to content

Archived

This topic is now archived and is closed to further replies.

jfee1212

Web inaccessible folder... how to access?

Recommended Posts

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?

Share this post


Link to post
Share on other sites
are you using windows?

does the folder exist uploads?

are you using a database?

post the script and form ok

if the folder uploads exist and the imagefilename exist this
will work on windows.

the uploads folder has to be in the same directory
as the php script with the below example.

[code]
<img src="uploads/imagefilename.jpg" >
[/code]

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
[code]
<img align='center' src='http://www.whatever.com/uploads/30.jpg' />
[/code]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

×

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.