Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8639743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:05:53+00:00 2026-06-12T11:05:53+00:00

I’m working on a project where i get images through an API from another

  • 0

I’m working on a project where i get images through an API from another site, and save the images locally on my server. I’ve been thinking, and i can’t decide if i should create a loader that displays the image, or just access the specific images directly? Is there any security concerns if i access them directly? Before i save the images on the server, i validate the content and check if it is a valid image, so i will always have valid images to display.

The image loader would work sort of like this. I create a controller (call it “load” for example). Then i could just call load with the image as a param, sort of like this:

http://example.com/load/file_name.jpg

And then i get the image through the load controller and display it. Is there any advantage to doing so or is it okay to access the image directly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:05:54+00:00Added an answer on June 12, 2026 at 11:05 am

    I will give you a use case of why someone (in this case, me) would serve images via PHP:

    On one of my applications, users can upload avatar images. These images are processed on upload, names changed into hashes, and stored in the filesystem. The hashed name is stored in the database in a table that associates the photo’s hash, the user id, and indicates whether or not this is their chosen profile photo.

    If I was only using a single image size on the website, I would have just stored the image path and whether it was their profile image and have been done with it. However, the site has multiple locations in which the image can be displayed and they are varying sizes. Depending on the size of the image that is requested, I check to see if a size close to it has been generated. If it has, then I send a jpeg header, use readfile on the image location and serve the image. If it hasn’t, then I take the originally uploaded image, resize it to the size I need, store it in the filesystem, and serve it.

    This way, I am not creating 5+ images every time someone uploads an image. The images are generated on-demand, both distributing cpu time and reducing filesystem usage because some image sizes may never be requested.

    So, essentially, if these apply to you, you do not need to serve via PHP/CI:

    • not restricting access
    • don’t need dynamic resizing
    • not storing images outside of the webroot

    If you’re curious, a request to one of my images looks like this:

    http://domain.com/photos/view/3d643a9cecaf8ae849be7ab094579698/s-128/photo.jpg

    Broken down:

    http://domain.com/[controller/view]/[image hash]/[square, rectangular, or original]-[size in px]/photo.jpg

    This serves an image with the following path:

    http://domain.com/images/uploads/3d/64/3a9cecaf8ae849be7ab094579698/3d643a9cecaf8ae849be7ab094579698_s_128.jpg

    I store the images in sub directories so that there are collisions and therefore avoid filesystem limits due to max files per directory and so on. I could also move the images outside of the webroot so that they are physically inaccessible to the web. Serving via PHP also has the added benefit of not exposing your upload directory’s location.

    I know the answer was long-winded, but I hope it helps you come to a decision.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.