Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jun 2007
    Location
    Canada
    Posts
    49
    Thanks
    1
    Thanked 1 Time in 1 Post

    View but not browse uploaded files

    On a shared server over which I have no configuration control...

    Can PHP upload files (pic, pdf, doc...) to a folder outside/above the web root but then make them available for display in a browser via links?

    /my_root
    /email
    /uploaded_files <--- put files here
    /www <--- my html and php are in here

    If so, how would I generate the links? I have tried reading the directory and creating file links with the full path (example: /server/user/my_root/uploaded_files/pic.jpg) but this doesn't work.

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Give us a link to the page that is displaying the links.
    (even though they're wrong).

    I'm thinking it will be like:

    <img src="../uploaded_files/pic.jpg" alt="" />

    But, if we can see your web page, we'd know.

  • #3
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,077
    Thanks
    2
    Thanked 320 Times in 312 Posts
    URL's for images/links... must point to http/https accessible locations. File system locations above your web document folder are not accessible through http/https requests. Likewise, things like absolute file system paths have no meaning in URL's. Remember that URL's are relative to your web document folder.

    You would need to write a .php script and put it in your web space that is the target of a link that is associated with a file. The .php script would then open and read the file from the folder above your web document folder and output any necessary headers/file contents to the browser.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    I guess I totally missed what he was asking.

  • #5
    New Coder
    Join Date
    Jun 2007
    Location
    Canada
    Posts
    49
    Thanks
    1
    Thanked 1 Time in 1 Post
    Thanks... that is what I thought.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •