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 8370595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:57:01+00:00 2026-06-09T13:57:01+00:00

All of this stuff is for example (names aren’t actual). Everything is also located

  • 0

All of this stuff is for example (names aren’t actual).

Everything is also located on localhost:8080 (USBWebserver 8.5)

Directory Structure:
(Files located on localhost:8080/[project_name])

/ajax
    /ajax_file.php
/img
    /250x250
        /[image_name].jpg

Code (From ajax_file.php):

$url = 'img/250x250/'.$image_name.'.jpg';
$url = file_exists($url);

This will return false.

I’ve tried an img_exists($url) function which used cUrl that did not work.

I’ve also tried:

$url = 'img/250x250/'.$image_name.'.jpg';
$image_check = getimagesize($url);

if (!is_array($image_check))
{
    $url = 'img/default_image.png';
}

but this returns a warning for getimagesize() saying no file or directory exists.

When I put $url = 'img/250x250/'.$image_name.'.jpg' into <img src="$url" /> the image shows up…but if the image does not exist then it comes up with a broken image…

How come anything I try to do fails in some way?

I want a default image to show up when the image is broken :/

EDIT

$url = 'img/products/250x250/'.$image_name.'.jpg';
$url = var_dump(file_exists($url));
Returns bool(false)

$url = '../img/products/250x250/'.$image_name.'.jpg';
$url = var_dump(file_exists($url));
Returns bool(false)
  • 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-09T13:57:02+00:00Added an answer on June 9, 2026 at 1:57 pm

    It appears as if you need to branch out of the ajax folder before accessing img folder?

    Try:

    $url = '../img/250x250/'.$image_name.'.jpg'; 
    

    @Alex Lunix

    My guess is that he put the img tag inside of the actual php page, not the ajax script.

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

Sidebar

Related Questions

i am pretty new to all this Monodroid stuff. I am porting my Windows
I'm a newbie to all this ASP.NET MVC stuff, and I was making some
I normally program in C++, so all this DataSource/DataSet/Binding stuff is confusing the hell
This script saves the files as /home/name/main/all my files and stuff . I want
just exploring c# 4. Trying to get my head around all this dynamic stuff.
Hi all this is my xml file with xsd defined as internal to it
hello all this seems to be my problem I have a table in mysql
How can I get all this to not only output on the screen, but
First of all this is my markup: <div class=first></div> <div class=second></div> <div class=second></div> <div
first of all: this is not the same as this . The ModelBackend has

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.