0

I have a page in symfony2 with a java applet and javascript functions that make the java applet load files. These files are user-dependant and each file has to be stored in the user folder.

Users have their folder in a directory located at the root of the symfony folder (/temp/). Now i need the files in these folders to be available (like an asset?).

// Controler ( What i have now )
$filepath = $this->get('kernel')->getRootDir().'/../temp/'.$userfolder;

// View ( what i would like -using twig )
{% set path = userfolder ~ '/' ~ filename %}
<a href="javascript:document.jmol.script('load {{ asset(path) }}; frame all');">link</a>
Elnur Abdurrakhimov
  • 44,533
  • 10
  • 148
  • 133
qdelettre
  • 1,873
  • 5
  • 25
  • 36

2 Answers2

0

I'm maybe late to the party, but... NEVER NEVER... NEVER! do a chmod 777 on anything. It's a huge security risk.

When it comes to files that you are serving through a web server such as Apache or NGINX, some general permissions will work for most cases.

The first thing is there is zero need for any files within the directories your serving to have the execute privilege.

When a web server serves these files, it only needs to be able to read from them.

Typically for files within a web server, you will want to use the permission 644 for files and 755 for directories.

Glenn
  • 36
  • 3
-1

If your doc root is at the web directory, you cannot do what you are trying to do. This is the "root" directory which means you cannot access anything outisde it from the browser. This is a good thing, otherwise people browsing your site would be able to access other directories like your app security configuration, etc...

You have several options:

a) use a subdirectory of web to hold your user files, for example web/temp

b) hold them somewhere else and copy them to a web subfolder as needed. This is what symfony does for assets

c) create a new controller which intercepts routes like 'temp/{user}/{filename}' and then serves these files from the directory where you hold the files.

Carlos Granados
  • 11,273
  • 1
  • 38
  • 44