Laravel-filemanager: I cant upload docx

Created on 10 Apr 2017  路  12Comments  路  Source: UniSharp/laravel-filemanager

My config files are :

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'],

// 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,        // !Important do not change

// The database column to identify a user. Make sure the value is unique.
// Ex: When set to 'id', the private folder of user will be named as the user id.
'user_field' => '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_html',

'images_folder_name' => 'user/user-',    // !Important do not change
'files_folder_name'  => 'files',     // !Important do not change

'shared_folder_name' => '',
'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,

'max_image_size' => 5000,
'max_file_size' => 10000,

// available since v1.3.0
'valid_image_mimetypes' => [
    'image/jpeg',
    'image/pjpeg',
    'image/png',
    'image/gif'
],

// available since v1.3.0
// only when '/laravel-filemanager?type=Files'
'valid_file_mimetypes' => [
    'image/jpeg',
    'image/pjpeg',
    'image/png',
    'image/gif',
    'application/pdf',
    'text/plain',
    'text/docx'
],

/*
|--------------------------------------------------------------------------
| 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',
],

];

When i upload PDF or simple TXT it works. But cant menage to work with doc and docx
thank you for your time

question

Most helpful comment

After 2hours trying we solve the problem easily.
In file vendor\unisharp\laravel-filemanager\src\Controllers\UploadController.php
Line 82 change code from:
File::move($file->getRealPath(), $new_file_path);
to:
move_uploaded_file($file->getRealPath(), $new_file_path);

All 12 comments

Upgrade to v1.7.1 and run php artisan vendor:publish --tag=lfm_config --force.

Yes, that fixed my problems. But now I have a problem with laravel on the server.
When I upload some PDF. Put a link to that pdf in TinyMCE I have laravel route error:
NotFoundHttpException in RouteCollection.php line 161

https://github.com/UniSharp/laravel-filemanager/issues/130
Maybe this is the same problem in link above but I can't fix it.

Do you have some idea?
I appreciate you time

I have found what is the problem. The problem is in file permission. When we upload throw file manager some file, automatically file permission on that file is 600. Haw i can change that , please help ?

O.K. I have found what is the problem :)
In Upload Controller on line 65.
Edit and put : http://php.net/manual/en/function.move-uploaded-file.php
move_uploaded_file ($file->path(), $new_file_path);
@g0110280 Thank you for helping me with this package.

config/lfm.php

'valid_file_mimetypes' => [
'image/jpeg',
'image/pjpeg',
'image/png',
'image/gif',
'image/svg+xml',
'application/pdf',
'application/docx',
'text/plain',
'image/vnd.microsoft.icon',
'image/x-icon',
'application/vnd.ms-excel','application/vnd.openxmlformats-officedocument.wordprocessingml.document','application/docx'

],

view : dropzone type mime

I'm also getting the same issue. only pdf and images are allowed to upload rest of the formats not supported. I'm using latest version 1.8 of laravel file manager. please tell me what might be the issue ??

modify your config/lfm.php with this:

'valid_file_mimetypes' => [
'image/jpeg',
'image/pjpeg',
'image/png',
'image/gif',
'image/svg+xml',
'application/pdf',
'application/docx',
'text/plain',
'image/vnd.microsoft.icon',
'image/x-icon',
'application/vnd.ms-excel','application/vnd.openxmlformats-officedocument.wordprocessingml.document','application/docx'
],

this is due to dropzone.js type mime, which is use for upload

I have tried by replacing this code also but still, I'm facing the same issue.
Can you please tell me what should I do??
should I make changes in dropzone.js file?

'valid_file_mimetypes' => [
'image/jpeg',
'image/pjpeg',
'image/png',
'image/gif',
'image/svg+xml',
'application/pdf',
'text/plain',
'application/vnd.ms-excel',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/docx',
'application/msword',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
],

this solved my problem which was not able to upload .xlsx files.

After 2hours trying we solve the problem easily.
In file vendor\unisharp\laravel-filemanager\src\Controllers\UploadController.php
Line 82 change code from:
File::move($file->getRealPath(), $new_file_path);
to:
move_uploaded_file($file->getRealPath(), $new_file_path);

Was this page helpful?
0 / 5 - 0 ratings