Reputation: 1980
I have a web application and I want to save data in a file instead of in the database.
My doubt is, where I should save the file? If I save it under the public directory, I could refer them with the assets to make the correct URL, but in the public directory, any person could see the file writing the complete URL. This shouldn't be because de data is reserved.
I think about the var directory, but I couldn't use the assets to make the correct URL to get or manage the files.
Where I should save the files and how I get/manage them?
Upvotes: 1
Views: 819
Reputation: 47584
If the data-file is local and hosted on the server's file system, the most logical place to store something like that would be the var
directory. Although nothing stops you from creating your own "var-like" directory and naming any way you like it. E.g. data
. But I would follow the conventions and create var/data
, easier for everyone.
That you can't use the asset()
function is irrelevant, because a data-file is not a web asset, but an infrastructure concern.
A file like this should not have a URL at all, but you would only access it through it's file system path.
Upvotes: 2