Jump to content

Web inaccessible folder... how to access?


jfee1212

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?
Link to comment
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]
Link to comment
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?
Link to comment
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]

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.