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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:40:42+00:00 2026-06-17T17:40:42+00:00

Im trying to check if a file exist on my /uploads folder of symfony

  • 0

Im trying to check if a file exist on my /uploads folder of symfony 2.

    $file = $this->getAssetUrl('/uploads/hd/'.$gift->getImage());
     if(file_exists($file)) return $this->getAssetUrl('/uploads/hd/'.$gift->getImage());
     else return $this->getAssetUrl('/uploads/large/'.$gift->getImage());

This is always returning false, i debugged all the strings and the paths are correct, checked by hand that the file exist. Any ideas?

  • 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-17T17:40:43+00:00Added an answer on June 17, 2026 at 5:40 pm

    getAssetUrl will only print the URI of whatever resource it is you’re printing, not the actual location.

    If you placed your project at /var/www/myProject, the path file_exists expects is /var/www/myProject/web/uploads/hd/, but it will only get /uploads/hd. It’ll look for a folder called “uploads” in your root directory. The first slash (“/”) means “system root dir” for PHP, while it means “root URI” for your browser.

    I believe if (file_exists($this->get('request')->getBasePath() . "/uploads/hd/" . $gift->getImage())) should do the trick.

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

Sidebar

Related Questions

Here I am trying to check that if file cmd.bat exist in temp folder
I'm trying to check if a file exists. If I use this: NSData *data
I'm trying to check if a file exists using bash. This is my code
I'm trying to use fileexists to check if a file exists on a network
I am trying to check for a specific file in a given directory. I
I am trying to check while not end of file in c programming. Can
I'm trying to check the validity of a particular 'stand-alone' code file from within
I'm trying to create a custom file/check in check out script for external hardrives,
I'm trying to check if server-running-p is available in my .emacs file before calling
as i am trying to upload a File, and i am trying to check

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.