Fuelphp redirect to file - php

Fuelphp redirect to file.
In fuelphp in the public folder i have a folder named files(public/files).
There i have some pdf and jpeg files i want to create a hyperlink to these files, so when i access the hiperlink it will take me to that file and view it in browser, like when you access a direct file on server in apache.
I created the hiperlink like this: myhost/index.php/files/myfile.pdf but i don't know how to access it. Do i have to setup something in routes? Or there is another way?
Thank you.

Create the hyperlink to myhost/files/myfile.pdf if your server can understand public/.htaccess (mod_rewrite).

Related

Laravel shows all the blade code on output

When I request a blade file directly from URL it displays all of the blade code, even if the user is not authenticate!
How can I handle this? or how can I block to execute blade file directly?
It seems like your Laravel application has been added to your webserver's document root. You shouldn't be able to access that file directly in the browser.
Your document root should be set to the public/ folder inside your Laravel project folder, making the index.php your only access point for your application.
See https://laravel.com/docs/8.x/deployment#server-configuration and https://laravel.com/docs/8.x/structure#the-public-directory for more details.

Laravel 404 error while viewing image saved in public directory of laravel project

I created Laravel project and able to make it work to get json output as well. However image link in json is not working.
https://android.factory2homes.com/
json: https://android.factory2homes.com/index.php/api/products
image link:https://android.factory2homes.com/index.php/public/12142.jpg
i tried creating symlink and copied same image in storage folder as well, but not able to make it work.
The public folder in a Laravel project is basically the root folder that shows up on the website URL.
For security issues, you really don't want the users to have the ability to write anything directly on the public folder, because if you are not careful they could overwrite your php scripts and have them do whatever they want.
So generaly speaking you create a simlink inside the public folder to the storage folder that is outside the public directory. Laravel has even a built in artisan command to do that exactly which is:
php artisan storage:link
The URL to any image stored in that folder would be in your example:
https://android.factory2homes.com/storage/12142.jpg
You do not have to put any .php file, or public or anything else.
if the image is inside public then I don't think you need to give the url like index.php/public/someimage.jpg you can just do www.yousiteurl.com/someinage.jpg
I resolved issue by savings images to Public_html folder instead of public folder in Laravel app root folder. Public_html is the path that is visible to public, hence other solutions weren't working.

Laravel, protecting a folder in public folder

I have a folder inside the public folder in Laravel app, this folder is called 'docs' and I want to protect it from unauthorised access. So basically when a user tries to access this folder they should get redirected to the login page. I tried doing this:
Route::get('\docs','DocsController#protected')->middleware('auth');
But Laravel doesn't even get triggered and the user goes directly to the folder.
You can use .htaccess file to protect this folder. But IMHO the better way is to move this folder from public, and access the docs using php code (using something like thephpleague/flysystem).

In Laravel 4.2, how to deny direct access to files in some folders inside public folder?

I am developing a project in laravel 4.2. In this project, inside public folder there are folders like css, js, img and images. I want to protect direct access of files inside js, css,img folder via url like by typing in browser like "www.example.com/css/style.css". How will I do that? Can anyone help? I saw some methods by using .htaccess file. But if I deny access via .htaccess file, I cannot access these file code too. Is there any method, that can be implemented by programming? Thanks

serving images from a filespool using zend framework

I have a quick question about how to serve data from a repository in a application that I am writing using the Zend Framework.
My current structure is:
/application
/filespool
/library
/public
In the filespool are a number of user identifiable folders that contain user content that is uploaded via forms, mainly jpg/png and pdf. This causes issues when trying to display an image back to the user as the path in my db to reference the file is:
../filespool/0/0/1/image.jpg
which I can't display in the view script as it can't reference the image.
What would be the best way of adding the image to the view script when trying to display it back to the user? I thought about adding the filespool folder to under public but would rather leave it where it is, as that move would require a lot of work to refactor the changes.
Thanks in advance...
i guess you could try 2 diferent things ( actually just one )...
use htacces to make a virtual directory for the file pool using rewrite ( not working )
make a php file in the public directorry that takes a parameter with the path and serves the files
EDIT
Spoke to soon ... you cant use htaccess ... and that is because its outside your document root so the server cant serve files from there.

Categories