Native Shopify Mobile App with 20 new features
Kickstart your hyperlocal marketplace in Corona pandemic with a starter guide
Android App Development
iOS App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Owner and Founder. Opencart
Top Partners
Here we will learn how to make a controller to upload a file and download the file in Symfony. Its quiet easy as in Symfony its quiet similar to how you do it in core PHP. So lets start! We are creating a controller which will upload a file and save its entry in a database table let the Entity that correspond to the Database Table is ‘UploadedFile’. Our entity ‘ UploadedFile’ will have 4 columns:
So lets start with our controller thats DefaultController, we have to create an action lets take uploadAction() so the controller will look like
Now we have to create a parameter named ‘file_directory’ in config.yml file to declare the path where the file is to be stored. So go to app/config/config.yml and add the below mentioned line under ‘parameters:‘ tag
Now its done when you will upload a file now the file will be stored in the path with a different name and you can see the entry in database. Now send your file as a form data and you can see this working.
Its time for the next step, as now we have file in our system so we are creating an action to download that file. You can take any way to distinguish between files but here I am using FileId so our link (route) will have FileId in it as
And you are ready to go! Access the link and you will have your file downloaded with the name it was uploaded not with the name it was saved on your server. For more info go to Symfony Components.
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
Great Product, Great Team, and Great Support Service. And if you want to add more features to the product, they can submit any idea that comes to your mind. They really care about their clients and we are really happy and honored to deal with Webkul.
Osama
USA
India
Global
Name
Email
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.