3
Below follows the folder structure:
/home/web/site/public_html
If I give an echo $_SERVER['DOCUMENT_ROOT']
I’ll get the path to public_html, but I’d like to make some files inaccessible directly by the URL so I’m putting these files inside the /home/web/site
but I wish I didn’t have to use ../../../
to return until arriving in /site
and having to guess how many folders I must go back to to get to the destination, has some easier way to point to a folder before default?
And if I want to call the files for a tag img
or video
through the src="algo..."
it would be a more practical solution to serve such files through a php script and limit the permissions of it? If yes how can I create it?
but this will leave the files accessible through the url in the browser, no?
– Leo Letto
You’re right. The files are not available to the web server, only to the application (that’s it, isn’t it?). I edited the answer ;)
– ShutUpMagda
if I call it an img tag works? example src="<? FILES? >"/rest of the way.jpg"
– Leo Letto
Not because then the file would need to be public. You can create a script
php
which has permission to access the file and return the image. something like: jpeg.php? image=filename.jpg.– ShutUpMagda
But ai would make it unviable since the script would need to be accessible on the web for me to call it through the url
– Leo Letto
Yes, but it’s not unfeasible. Whoever accesses the script does not necessarily access the image. And you can configure the script to give access with permission (or authentication), or parameter validation, etc. I can test, but recommend that you edit your question and inform (clearly) that, although restricted, the images would need to be shown in the browser ;)
– ShutUpMagda
Edited, in fact these are video files, so it is important that they are accessible through src tags but not by the direct path in the url
– Leo Letto