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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:20:06+00:00 2026-06-01T04:20:06+00:00

In my Symfony 2 project, I have a page displaying information about an entity.

  • 0

In my Symfony 2 project, I have a page displaying information about an entity. On this page there is also a link to a file associated to this entity.

The page is secured and it can be displayed only if the user as a specific role. The expected role is not the same for every entity so it’s tested dynamicaly in the Action.

My problem is that even if the page is secured, anyone can access the file via its URL. I’d like it to be downloadable only if the role matches the one for the page display.

Any suggestion on how I should do it, or where to start looking ?

  • 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-01T04:20:08+00:00Added an answer on June 1, 2026 at 4:20 am

    Move the file outside of the public directory so it’s not accessible via a URL. In the controller if a user has the correct permissions then allow the user to download the file.

    You could use this in your controller:

    $headers = array('Content-Type'     => 'application/pdf',
                     'Content-Disposition' => 'inline; filename="file1.pdf"');
    
    return new Response(file_get_contents($file), 200, $headers); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a Symfony project and I currently have this: <?php echo
I have set up some custom symfony project-level settings in the file config/project.yml following
I have this wrapper to load a symfony project from within Joomla class NZGBCComponentHelper
In a Symfony project, I have the following php code inside a YML file.
I have a symfony project. There is a website and a rest API that
Problem: I have a symfony project with a database full of production data I
I have a symfony project with the followin structure SDCU |-app |-----cache |-----logs |-bin
When I update my Symfony2 project I always have to do this: root@xxx:/var/www/project# php
Ex. in Symfony 1: http://www.symfony-project.org/jobeet/1_2/Doctrine/en/06#chapter_06_custom_configuration Where should I store global data, which file?
On my local machine, the symfony project I have created works perfectly. I have

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.