简体   繁体   中英

file path returning Failed to load resource: the server responded with a status of 404 (Not Found)

I am getting this error message

Failed to load resource: the server responded with a status of 404 (Not Found)

I have a file class_start_paperwork.php file that is in the include folder creates pdfs and jpgs to the private folder

so

I am trying to show the image in the user_group_start_paperwork_esign2.php file which is in the public_html folder

"/root  
    /private
        /scratch
            /1387.2742.1487969899-0.jpg"


"/public_html
        /include
            /class_start_paperwork
        /user_group_start_paperwork_esign2.php"

it is creating the images

I just can't load the jpgs

<img src= '../private/scratch/1387.2742.1487969899.0.jpg'  width=800 height=1100 />

is what is in the page source is

It seems like the /private folder is outside the public world zone. You would have to move the contents of /private folder into the public zone and relink for the web browser to be able to access.

If you would be displaying the images using server side language, that would be a possibility with the correct permissions.

This answer has some good info: Display images from private directory

Ideally you'd just make that directory accessible, but if that's absolutely not possible then you can do this:

myimage.php

$file = 'privatedir/image.jpg'; $type = 'image/jpeg'; header('Content-Type:'.$type); header('Content-Length: ' . filesize($file)); readfile($file); exit();

Then use myimage.php as the img tag src.

this worked perfectly

myimage.php

$file = 'privatedir/image.jpg'; $type = 'image/jpeg'; header('Content-Type:'.$type); header('Content-Length: ' . filesize($file)); readfile($file); exit();

Then use myimage.php as the img tag src.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM