Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

yibrah's avatar

File upload in Laravel application hosted in shared hosting

I host a Laravel application in a shared hosting. I put the project files like this: /public_html - contains the public files of Laravel app /core_app - contains all files except the public folder of the Laravel app

During development, everything is fine for me in uploading images. But in shared hosting, it happens an error in uploading images. Here is what the error message says:

Whoops, looks like something went wrong. (1/1) LogicException Unable to guess the mime type as no guessers are available (Did you enable the php_fileinfo extension?)

in MimeTypeGuesser.php (line 135) at MimeTypeGuesser->guess('/tmp/phpC0Akib') in File.php (line 79) at File->getMimeType() in File.php (line 58) at File->guessExtension() in ValidatesAttributes.php (line 926) .....

0 likes
5 replies
burlresearch's avatar
Level 40

php_fileinfo is a pretty routine PHP module, if you're having issues with this it's most likely an issue of the php version on hosting server.

Server requirements for modern Laravel are PHP >= 7.0.0:

https://laravel.com/docs/master/installation#server-requirements

plus some required modules. Can you prove your host meets these requirements?

Perhaps you can find an alternative hosting provider that does?

yibrah's avatar

You are right! My server's PHP version was 5.6.32. I upgrade it to 7.0.0 and activate php_fileinfo. It works fine in image upload to /core_app/public/images but not to /public_html/images.

I went one step through your help. I need additional help in this issue. Thanks in advance.

abiodun_solomon's avatar

Edit appServiceProvider.php and add

public function register()
{
    $this->app->bind('path.public', function() {
        realpath(base_path().'/../public_html');
    });
}

then edit public_html/index.php and add

$app->bind('path.public', function() {
    return __DIR__;
})
RobsonZindoga1's avatar

my php version and everything is fine. When I upload a file, the route gets stored in the database but no image is uploaded in my storage on the hosted website which is on my cpanel. may someone help.

RobsonZindoga1's avatar

am not getting any error except file not found when I try to access it

Please or to participate in this conversation.