Welcome Guest, Not a member yet? Register   Sign In
Writable directory question
#1

My question is about work with /writable directory.
Totally like the approach of setting index.php into separate folder and dividing writable files as separate.
But when I tried to recreate the workflow for myself, I faced the problem, that whenever I put for example:
  • /writable/minified - stylesheets and scripts that are dynamically minified and written during the load.

  • /writable/uploads/avatar.gif - dummy image file for test.
How can I access them from frontend side, for example in header, while loading stylesheets:
Code:
<link rel='stylesheet' type='text/css' href='[domain]/writable/minified/core.min.css'>


And I understand that by logic you simply can't access secured and outer directory. Then how to get the content of the file by link? Through some specific helper and read of file?

Or for e.g. for load of image:
Code:
<img class="preloader-logo" src="[domain]/writable/uploads/avatar.gif" />


anywhere on the frontend etc.

Thank you for information and really hope you will not delete question or can answer me directly. I'm confused about this one.

P.S
Jim Parry answered me: I can point out that only folders/files underneath "public" are intended to be browser accessible. The writable folder isn't.
Does it mean that /writable folder serves only for something like cache saving, and actions like user file saving should be done to "public" folder?
Reply
#2

Correct. The writable folder is for caching, etc. You can use it for file uploads if you have a action somewhere that can read that file and send it on to the browser. Basically, the writable folder is to help solve the question of, "Which folders have to be writable in my entire application" instead of having 2 or 3 folders (log, cache) under the application folder that you have to remember to make writable.
Reply
#3

(02-13-2017, 08:24 PM)kilishan Wrote: Correct. The writable folder is for caching, etc. You can use it for file uploads if you have a action somewhere that can read that file and send it on to the browser. Basically, the writable folder is to help solve the question of, "Which folders have to be writable in my entire application" instead of having 2 or 3 folders (log, cache) under the application folder that you have to remember to make writable.

Thank you for the rapid answer)

Maybe I'm not right, but in my example of /writable/minified - I think I use writable folder as it suppose to serve for.

My point here is that actions are created on the server side, without any user's interaction, almost like your cache example and for not saving files e.g. stylesheets and scripts publicly or maybe to add additional checks through Escaper etc. won't it be wise to send them thought some controller that will secure them and then output to view?

I think questions here are:
- Is there such necessity or need in such complicated solution and will this make website more secured for some code implementations from front? E.g. upload of file from user that will not be directly accessed but can be viewed from frontend as usual.
- I can check file's content and then get it with readfile or file_get_contents. Both of this functions return the content of file or it's bite's representation. Then how to connect frontend link and this representation. E.g.


Code:
<link rel='stylesheet' type='text/css' href='[domain]/writable/files/avatar.gif'>


In this case /writable is Controller, /files is Method for working with files and search them through entire directory.
Is it a good approach or stupid?

Thank you very much again.
Reply
#4

The writable folder should not be used for your page assets create an assets folder in the public folder.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

You need to interpret the writable folder as internal storage room for the CodeIgniter system itself. You should create a seperate folder inside your public root for css/js/images files for the frontend part of your application.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB