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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:22:28+00:00 2026-06-11T06:22:28+00:00

I have a Symfony2 project with user management (FOsUserbundle & Sonata bundles). In some

  • 0

I have a Symfony2 project with user management (FOsUserbundle & Sonata bundles). In some case of my application, i need to create files for users, and i want to store them. The files might be big so i exclude storing them in sessions/local storage.

First question :
Is there a symfony2 pattern to handle user generated files and storage ?
Where does these files should be placed ? Which directory ?

Second question :
I have a big file that my app need to use. Users shouldn’t have access to this file but mainly my app controllers have to. What is the best secured way to store this file and restrain access ?

  • 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-11T06:22:29+00:00Added an answer on June 11, 2026 at 6:22 am

    First Question:
    depending on the number of files each user has, I would use some kind of naming convention. e.g. temp/[username]/file1.dat or temp/[username].dat
    You can implement this strategy by following the symfony2 cookbock for file uploads on entities and check the function:

    public function preUpload()
    {
        if (null !== $this->file) {
            // do whatever you want to generate a unique name
            $this->path = uniqid().'.'.$this->file->guessExtension();
        }
    }
    

    Here is the filename generated, and you can easily set the username instead of some random “uniqueid()”.

    Second Question
    Securing files is in my opinion best implemented via a folder that is not accesible through the web.
    For example if you have the following structure:

    myproject    
      app    
      src    
      vendor    
      web  <-- your domain points to this folder    
      save_files
    

    then you can store your files in the save_folder that it is not accesible via direct web access. In your application / controller you can access it via the filesystem or use some abstraction like the KnpGaufretteBundle

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

Sidebar

Related Questions

its my first real project with Symfony. i need to have some settings like
I need to create some type of Quizz app witch have to have 2
I am trying to create a symfony2 application. The main idea behind the project
I have a symfony2 project and I would like to create route (prefix) which
I have a Symfony2 project with a MySQL db: #app/config/config.yml doctrine: dbal: driver: %database_driver%
When I update my Symfony2 project I always have to do this: root@xxx:/var/www/project# php
I have a question about symfony2. I have a project and I am using
I have a regular class in my Symfony2 project: class RangeColumn extends Column{ //...
How can I create a new project that only uses the Symfony2 Console component?
I have a Symfony2 project with its own database, and now I want to

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.