php file issue

Discussion in 'Webmaster Discussion' started by swordsinfo, Jul 1, 2013.

  1. swordsinfo

    swordsinfo New Member

    Hi guys quick q - Im looking to download files that are located outside the web root. During the upload process the users upload to a folder that was outside the root of the site (for security reasons). I now want to do the reverse for the admin users to download the files I have tried the following but to no avail

    I think maybe I need to add something to the conf file or the htaccess maybe - according to host permissions are ok!

    Is absolute apths an option also??

    $file=$_SERVER["DOCUMENT_ROOT"]. "/../uploads/".$filename;
  2. Forbairt

    Forbairt Portfolio Building

    Is this on shared hosting?

    Are you allowed to upload things outside the web root and you're sure they are uploading ok? you've checked via FTP? :)
  3. swordsinfo

    swordsinfo New Member

    Yes upload was not a prob and have full access to files. But cant get the php files to browse to that folder, maybe that sort of config is only for one way. I cant get script to find files!!

    I wonder would absolute paths work or alias?? Or is there actually a simple fix?
    Thanks again for input.

  4. Forbairt

    Forbairt Portfolio Building

    Sounds like a permissions issue

    I'd suggest throwing up a file such as ...

    if ($handle = opendir('.')) {
        while (false !== ($entry = readdir($handle))) {
            if ($entry != "." && $entry != "..") {
                echo "$entry<br />";
    then changing the directory you're listing to if ($handle = opendir('./../')) {

    and so on ... and then into your uploads folder ...
  5. swordsinfo

    swordsinfo New Member

    lovely hurling cheers for that bit of code - ill give that a whirl if it doesnt work do you have any recommendations - I was thinking alias? THere not that many files in the folder say 200 so I could move them to inside the web root but figure an alias to the folder would be easier. Site is with Letsh0$t so I presume I would have to ask them for this or can it be done thorugh cpanel?
  6. swordsinfo

    swordsinfo New Member

    Cheers for the code snippit the code worked perfectly to identify the problem - its listing other folders and sites in the public_html folder except my uploads folder - the perms on the uploads folder are set to 777 but it still wont list? any ideas?
  7. swordsinfo

    swordsinfo New Member

    ignore the last it is seeing the folder but cannot open it

    below is the process of the listing i added the following code

    if ($entry == "uploads") {
    $entrytemp = opendir($entry);


    Warning: opendir(uploads) [function.opendir]: failed to open dir: No such file or directory in /home/eurotime/public_html/ on line 39

    so its lsiting the directory but cannot open it??

Share This Page