Welcome Guest, Not a member yet? Register   Sign In
Files in "writable" / Preview via "http" not working, ideas?
#1

Hey folks,
I try to code something like a file browser (Win: Explorer/Mac: Finder), very small but working with all folders and files.
My understanding is to create a subfolder in "writable", and it works, I can do and view all files and folders, upload works too, but... my "Preview function" has some problems. 
I use a javascript to preview .pdf files and this script needs an url.
Maybe I missed something, but building urls for me is only working if files are in the "public" directory, files in the directory "writable" cannot accessed by url, e.g. https://mydomain/writable/server/images/photo.jpg
It seems I have to code a separate controller to make these files visible, but I'm not sure. A want to avoid to move the server folder to public (or should I???). In public folder it wouldn't be a problem.

Has anybody a solution or idea?
Reply
#2

If you store files in a "writable" directory, then you need a controller that will handle access to those files.
Reply
#3

iRedds nailed it. If you want to read more these are using called “media servers”. You need a routed controller that can “serve” the files since the writable folder is not web-accessible.

An alternative (but make sure you handle security implications) is to create a symlink in public/ to the files.

You may be interested in this similar project: https://github.com/tattersoftware/codeigniter4-files
Reply




Theme © iAndrew 2016 - Forum software by © MyBB