Search code examples
phpimageloadinternal-server-error

Load many images from php file sometimes throw 500 internal server error


I'm loading a gallery of many images from the root of the server ("behind" public_html). For this job I use a php file which, obtained the name with $_GET, find the image and print it like in the code.

Nothing strange, if not that when the images are many, I get an highly variable number of 500 internal server error.

I'm doing this because I wanted to dynamically manipulate their width/height and maybe adding a watermark. But at the moment I'm not doing that, first I need to solve this problem.

My doubt is: - Is the problem that I load all of them with the same file and I overload the php? - The images loaded in this manner, are correctly cached by the browser? - If I don't want the user for directly access the images, what should I do? - Should I just surrender and upload normally the images on public_html?

header('Content-Type: '.mime_content_type($filepath)); readfile($filepath);


Solution

  • I "found the solution". There is no solution. The classic route is hundred times faster than putting PHP in the middle of it.

    Theres no way around if the images are many.