laravel file upload on a project on a hosted project - php

I have hosted my laravel application, before this file uploads and everything was working fine, but after I put it on cpanel, File uploading is nolonger working.
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
],
],
this is my code, may someone help. in my .env file I inserted my app url for the website which is working file except for file upload
Regards

Related

Image source not readable when trying to load images that are stored on S3 in laravel 5.2

I am trying to run a copy of a website locally but for some reason none of the images work. They are stored on an S3 bucket.
In my config/filesystems.php the default is s3:
'default' => 's3',
My keys are the same as on the live site:
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID', 'key'),
'secret' => env('AWS_SECRET_ACCESS_KEY', 'key'),
'region' => 'eu-central-1',
'bucket' => 'storage.website.nl',
'cloud' => 'cloud.website.nl'
],
],
The only difference is my storage/app does not have a public folder with all the media in it like on the live site. But this should be created I think with something similar like php artisan storage:link except this command does not work in laravel 5.2.
What can I do to fix that?

chmod(): Operation not permitted when upload file with laravel 6

I am using file system storage to upload files. When I change filesystem_driver from local to public I get this error :
vendor/league/flysystem/src/Adapter/Local.php:367
public function setVisibility($path, $visibility){
$location = $this->applyPathPrefix($path);
$type = is_dir($location) ? 'dir' : 'file';
$success = chmod($location, $this->permissionMap[$type][$visibility]); // line 367
if ($success === false) {
return false;
}
Disk settings
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
'permissions' => [
'file' => [
'public' => 0664,
'private' => 0600,
],
'dir' => [
'public' => 0775,
'private' => 0700,
],
],
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
],
],
I tried to change the file permissions according to this post, but it doesn't work. If I change the filesystem_driver to local I cannot display the pictures in front end. This is a local development environment WSL Ubuntu 18.
What do I do wrong here?
problem was cmod is not support under ntfs file system https://github.com/Microsoft/WSL/issues/81

Images doesn't save in the correct location in Laravel

I have an image upload form in my Laravel project.
I want to save the upload image into public/images/ location.
But image upload into public/app/images location.
From where this app coming !!
config/filesystem.php
'disks' => [
'local' => [
'driver' => 'local',
'root' => public_path(''),
],
'public' => [
'driver' => 'local',
'root' => public_path(''),
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => 'your-key',
'secret' => 'your-secret',
'region' => 'your-region',
'bucket' => 'your-bucket',
],
],
controller
if($this->request->hasFile('photo'))
{
$image_url = $this->request->photo->store('/images/campaign/large');
$image = substr($image_url, strrpos($image_url, '/') + 1);
}
Where is the mistake ? Anybody help please?
Thanks in advance

laravel5 create custom disk for uploading photo

I'm using laravel 5.6 and i wanted to create my custom disk for uploading images
and i received this error
InvalidArgumentException Driver [] is not supported.
this is how i save file in controller
$cover = $request->file('cover_image');
$extension = $cover->getClientOriginalExtension();
Storage::disk('test')->put($cover->getFilename().'.'.$extension, File::get($cover));
this is my config/filesystems.php
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'test' => [
'driver' => 'local',
'root' => storage_path(),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public/asghar'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
],
the error occurred because my configuration was cached.
probably I accidentally used config:cache or sth similar.
the issue resolved by clearing the config cache using this command
php artisan config:clear

Config error Laravel 5.5 admin

I have just integrated laravel-admin in my Laravel project. When I try to get login then it shows me an error message at the top of every inner pages.
Please check the screenshot:
And here is the 'disks' array from my filesystems.php:
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => env('AWS_KEY'),
'secret' => env('AWS_SECRET'),
'region' => env('AWS_REGION'),
'bucket' => env('AWS_BUCKET'),
],
],
I have tried to find out the issue but nothing helped.
may be you need to add admin to disks array like this
'disks' => [
'admin' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => env('AWS_KEY'),
'secret' => env('AWS_SECRET'),
'region' => env('AWS_REGION'),
'bucket' => env('AWS_BUCKET'),
],
],

Categories