File Upload Issue

andrea - 6 months ago

Hello there, I'm quite new to Laravel (therefore PyroCMS) and I'm experiencing an issue with file upload in admin panel. I have followed every step for a PyroCMS fresh install:

composer create-project pyrocms/pyrocms dns setted to have /public/ as root folder permissions setted to 775 (at first) and 777 (at last) for almost all folders (public, storage, resources, bootstrap and so on)

When I try to upload a file using admin panel "admin/files/upload/images" a popup shouting "Page Not Found (404)" shows up.

I'm using a virtual host with Nginx

Answer

- 6 months ago

This happens when you have NGINX skip the controller before checking for files in the CMS. Try modifying your location bracket for files like this:

location ~* \.(?:jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|eot|mp4|ogg|ogv|webm)$ {
    try_files $uri $uri/ /index.php?$query_string; # hit the CMS first to see if it can handle it
    access_log off;
    log_not_found off;
}

ryanthompson - 6 months ago

This happens when you have NGINX skip the controller before checking for files in the CMS. Try modifying your location bracket for files like this:

location ~* \.(?:jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|eot|mp4|ogg|ogv|webm)$ {
    try_files $uri $uri/ /index.php?$query_string; # hit the CMS first to see if it can handle it
    access_log off;
    log_not_found off;
}

andrea - 6 months ago

Thank you very much

ryanthompson - 5 months ago

Sure thing! Be sure to mark the answer so others can identify it quickly as well ^_^