Hi,
I'm using last version a i can upload image successfully in admin panel with ['web','auth:admin'] middleware . but in website i can't see my uploaded image. however when i login to admin panel images show me in website. what's problem with my configuration.
/*
|--------------------------------------------------------------------------
| Routing
|--------------------------------------------------------------------------
*/
// Include to pre-defined routes from package or not. Middlewares
'use_package_routes' => true,
// Middlewares which should be applied to all package routes.
// For laravel 5.1 and before, remove 'web' from the array.
'middlewares' => ['web','auth:admin'],
// The url to this package. Change it if necessary.
'prefix' => 'laravel-filemanager',
/*
|--------------------------------------------------------------------------
| Multi-User Mode
|--------------------------------------------------------------------------
*/
// If true, private folders will be created for each signed-in user.
'allow_multi_user' => false,
// If true, share folder will be created when allow_multi_user is true.
'allow_share_folder' => true,
// Flexibla way to customize client folders accessibility
// Ex: The private folder of user will be named as the user id.
'user_field' => function() {
return auth()->guard('admin')->user()->id;
},
/*
|--------------------------------------------------------------------------
| Working Directory
|--------------------------------------------------------------------------
*/
// Which folder to store files in project, fill in 'public', 'resources', 'storage' and so on.
// You should create routes to serve images if it is not set to public.
'base_directory' => 'public',
'images_folder_name' => 'photos',
'files_folder_name' => 'files',
'shared_folder_name' => 'shares',
'thumb_folder_name' => 'thumbs',
/*
|--------------------------------------------------------------------------
| Startup Views
|--------------------------------------------------------------------------
*/
// The default display type for items.
// Supported: "grid", "list"
'images_startup_view' => 'grid',
'files_startup_view' => 'list',
/*
|--------------------------------------------------------------------------
| Upload / Validation
|--------------------------------------------------------------------------
*/
// If true, the uploaded file will be renamed to uniqid() + file extension.
'rename_file' => false,
// If rename_file set to false and this set to true, then non-alphanumeric characters in filename will be replaced.
'alphanumeric_filename' => true,
// If true, non-alphanumeric folder name will be rejected.
'alphanumeric_directory' => false,
// If true, the uploading file's size will be verified for over than max_image_size/max_file_size.
'should_validate_size' => false,
'max_image_size' => 50000,
'max_file_size' => 50000,
// If true, the uploading file's mime type will be valid in valid_image_mimetypes/valid_file_mimetypes.
'should_validate_mime' => false,
// available since v1.3.0
'valid_image_mimetypes' => [
'image/jpeg',
'image/pjpeg',
'image/png',
'image/gif',
'image/svg+xml',
],
// available since v1.3.0
// only when '/laravel-filemanager?type=Files'
'valid_file_mimetypes' => [
'image/jpeg',
'image/pjpeg',
'image/png',
'image/gif',
'image/svg+xml',
'application/pdf',
'text/plain',
],
/*
|--------------------------------------------------------------------------
| Image / Folder Setting
|--------------------------------------------------------------------------
*/
'thumb_img_width' => 200,
'thumb_img_height' => 200,
/*
|--------------------------------------------------------------------------
| File Extension Information
|--------------------------------------------------------------------------
*/
'file_type_array' => [
'pdf' => 'Adobe Acrobat',
'doc' => 'Microsoft Word',
'docx' => 'Microsoft Word',
'xls' => 'Microsoft Excel',
'xlsx' => 'Microsoft Excel',
'zip' => 'Archive',
'gif' => 'GIF Image',
'jpg' => 'JPEG Image',
'jpeg' => 'JPEG Image',
'png' => 'PNG Image',
'ppt' => 'Microsoft PowerPoint',
'pptx' => 'Microsoft PowerPoint',
],
'file_icon_array' => [
'pdf' => 'fa-file-pdf-o',
'doc' => 'fa-file-word-o',
'docx' => 'fa-file-word-o',
'xls' => 'fa-file-excel-o',
'xlsx' => 'fa-file-excel-o',
'zip' => 'fa-file-archive-o',
'gif' => 'fa-file-image-o',
'jpg' => 'fa-file-image-o',
'jpeg' => 'fa-file-image-o',
'png' => 'fa-file-image-o',
'ppt' => 'fa-file-powerpoint-o',
'pptx' => 'fa-file-powerpoint-o',
],
/*
|--------------------------------------------------------------------------
| php.ini override
|--------------------------------------------------------------------------
*/
// These values override your php.ini settings before uploading files
// Set these to false to ingnore and apply your php.ini settings
'php_ini_overrides' => [
'memory_limit' => '256M'
]
Did you get any error message in the console?
No. There isn't any error.
Evrything is ok when i'm login at admin panel and show me images in website. after logout don't show me anything
The "auth" middleware was set in the config. So this package requires users to login to make all APIs work. Since user can upload files through this package, you should treat this package as a part of your admin panel.
I use "auth:admin" to prevent upload images by guest user. admin uploads image to show it for public user.
for example when admin adds images to ckfinder for a post , images don't show in website but it should show that
There is a problem like me in this issue https://github.com/UniSharp/laravel-filemanager/issues/305
This is a issue with routing, routes here is wrapped into route group which is protected by middlewares. Will fix this in next release.
Hi, I'm having same issue. Once the user is logged, all images are loaded but for guest usesr no image appears. Let's wait for the fix. Thanks.
While the fix is not applied, do you know if is there any (security) problem setting this two routes in a group without middleware ?
// public access
Route::group(compact('prefix', 'as', 'namespace'), function () {
// Get file when base_directory isn't public
$images_url = '/' . \Config::get('lfm.images_folder_name') . '/{base_path}/{image_name}';
$files_url = '/' . \Config::get('lfm.files_folder_name') . '/{base_path}/{file_name}';
Route::get($images_url, 'RedirectController@getImage')
->where('image_name', '.*');
Route::get($files_url, 'RedirectController@getFIle')
->where('file_name', '.*');
});
Thanks
Can you tell us the date of the next version
Having same issue, when will this be fixed? This is a big concern since the guest users cant see the images uploaded from admin.
Already fixed. Please upgrade to v1.8.1.
what to do is i need another auth in middleware ? like
'middlewares' => ['web', 'auth:manager', 'auth:client'],
@saifuldhaka you can set up middlewares in config/lfm.php. Otherwise you should copy all routes of this package and paste them to your routes file.
hi @g0110280 i tried this way but not working ,
'middlewares' => ['web', 'auth:manager'], works only manager,
'middlewares' => ['web', 'auth:client'], works with client.
but i need both manager and client working same time
@g0110280 here is my lfm.php
<?php
return [
/*
|--------------------------------------------------------------------------
| Routing
|--------------------------------------------------------------------------
*/
// Include to pre-defined routes from package or not. Middlewares
'use_package_routes' => true,
// Middlewares which should be applied to all package routes.
// For laravel 5.1 and before, remove 'web' from the array.
//'middlewares' => ['web', 'auth:manager', 'auth:client'],
//'middlewares' => ['web', 'auth:manager'],
//'middlewares' => ['web', 'auth:client'],
//'middlewares' => ['web', 'auth'],
'middlewares' => ['web'],
// The url to this package. Change it if necessary.
'prefix' => 'laravel-filemanager',
/*
|--------------------------------------------------------------------------
| Multi-User Mode
|--------------------------------------------------------------------------
*/
// If true, private folders will be created for each signed-in user.
'allow_multi_user' => true,
// If true, share folder will be created when allow_multi_user is true.
'allow_share_folder' => true,
// Flexibla way to customize client folders accessibility
// If you want to customize client folders, publish tag="lfm_handler"
// Then you can rewrite userField function in App\Handler\ConfigHander class
// And set 'user_field' to App\Handler\ConfigHander::class
// Ex: The private folder of user will be named as the user id.
//'user_field' => Unisharp\Laravelfilemanager\Handlers\ConfigHandler::class,
'user_field' => App\Handlers\ConfigHandler::class,
/*
|--------------------------------------------------------------------------
| Working Directory
|--------------------------------------------------------------------------
*/
// Which folder to store files in project, fill in 'public', 'resources', 'storage' and so on.
// You should create routes to serve images if it is not set to public.
'base_directory' => 'laravel/public',
'images_folder_name' => 'photos',
'files_folder_name' => 'files',
'shared_folder_name' => 'shares',
'thumb_folder_name' => 'thumbs',
/*
|--------------------------------------------------------------------------
| Startup Views
|--------------------------------------------------------------------------
*/
// The default display type for items.
// Supported: "grid", "list"
'images_startup_view' => 'grid',
'files_startup_view' => 'list',
/*
|--------------------------------------------------------------------------
| Upload / Validation
|--------------------------------------------------------------------------
*/
// If true, the uploaded file will be renamed to uniqid() + file extension.
'rename_file' => false,
// If rename_file set to false and this set to true, then non-alphanumeric characters in filename will be replaced.
'alphanumeric_filename' => false,
// If true, non-alphanumeric folder name will be rejected.
'alphanumeric_directory' => false,
// If true, the uploading file's size will be verified for over than max_image_size/max_file_size.
'should_validate_size' => false,
'max_image_size' => 50000,
'max_file_size' => 50000,
// If true, the uploading file's mime type will be valid in valid_image_mimetypes/valid_file_mimetypes.
'should_validate_mime' => false,
// available since v1.3.0
'valid_image_mimetypes' => [
'image/jpeg',
'image/pjpeg',
'image/png',
'image/gif',
'image/svg+xml',
],
// available since v1.3.0
// only when '/laravel-filemanager?type=Files'
'valid_file_mimetypes' => [
'image/jpeg',
'image/pjpeg',
'image/png',
'image/gif',
'image/svg+xml',
'application/pdf',
'text/plain',
],
/*
|--------------------------------------------------------------------------
| Image / Folder Setting
|--------------------------------------------------------------------------
*/
'thumb_img_width' => 200,
'thumb_img_height' => 200,
/*
|--------------------------------------------------------------------------
| File Extension Information
|--------------------------------------------------------------------------
*/
'file_type_array' => [
'pdf' => 'Adobe Acrobat',
'doc' => 'Microsoft Word',
'docx' => 'Microsoft Word',
'xls' => 'Microsoft Excel',
'xlsx' => 'Microsoft Excel',
'zip' => 'Archive',
'gif' => 'GIF Image',
'jpg' => 'JPEG Image',
'jpeg' => 'JPEG Image',
'png' => 'PNG Image',
'ppt' => 'Microsoft PowerPoint',
'pptx' => 'Microsoft PowerPoint',
],
'file_icon_array' => [
'pdf' => 'fa-file-pdf-o',
'doc' => 'fa-file-word-o',
'docx' => 'fa-file-word-o',
'xls' => 'fa-file-excel-o',
'xlsx' => 'fa-file-excel-o',
'zip' => 'fa-file-archive-o',
'gif' => 'fa-file-image-o',
'jpg' => 'fa-file-image-o',
'jpeg' => 'fa-file-image-o',
'png' => 'fa-file-image-o',
'ppt' => 'fa-file-powerpoint-o',
'pptx' => 'fa-file-powerpoint-o',
],
/*
|--------------------------------------------------------------------------
| php.ini override
|--------------------------------------------------------------------------
|
| These values override your php.ini settings before uploading files
| Set these to false to ingnore and apply your php.ini settings
|
| Please note that the 'upload_max_filesize' & 'post_max_size'
| directives are not supported.
*/
'php_ini_overrides' => [
'memory_limit' => '256M',
],
];
Please try copying all routes of this package and paste them to your routes file, and set use_package_routes to false. Routes are here: https://github.com/UniSharp/laravel-filemanager/blob/master/src/routes.php .
@g0110280
is it under vendor ?
what will happen after update ?
Sorry for late reply. Routes won't be affected even after running update. If you still have problems, please feel free to open a new issue.
thank you for your reply. I think this problem solved in last version