Magento2: Custom attribute - File not allowing uploads

Created on 5 Oct 2017  路  12Comments  路  Source: magento/magento2


Preconditions


  1. Magento 2.1.9
  2. PHP 7.0.2
  3. MySQL 5.7

Steps to reproduce

  1. Create a customer file upload attribute
  2. View the customer information in the CMS
  3. upload a file - in my case a PDF

Expected result

  1. the uploaded file appears in the customer form

Actual result

  1. Popup appears stating something went wrong with saving the file
  2. In the apache error log the following appears

[2017-10-05 14:37:15] main.CRITICAL: Exception: Notice: Undefined index: path in /var/www/vhosts/Rosita/public/vendor/magento/module-customer/Model/FileUploader.php on line 113 in /var/www/vhosts/Rosita/public/vendor/magento/framework/App/ErrorHandler.php:61
Stack trace:

0 /var/www/vhosts/Rosita/public/vendor/magento/module-customer/Model/FileUploader.php(113): Magento\Framework\App\ErrorHandler->handler(8, 'Undefined index...', '/var/www/vhosts...', 113, Array)

1 /var/www/vhosts/Rosita/public/vendor/magento/module-customer/Controller/Adminhtml/File/Customer/Upload.php(85): Magento\Customer\Model\FileUploader->upload()

2 /var/www/vhosts/Rosita/public/vendor/magento/framework/App/Action/Action.php(102): Magento\Customer\Controller\Adminhtml\File\Customer\Upload->execute()

3 /var/www/vhosts/Rosita/public/vendor/magento/module-backend/App/AbstractAction.php(226): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))

4 /var/www/vhosts/Rosita/public/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Backend\App\AbstractAction->dispatch(Object(Magento\Framework\App\Request\Http))

5 /var/www/vhosts/Rosita/public/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Customer\Controller\Adminhtml\File\Customer\Upload\Interceptor->___callParent('dispatch', Array)

6 /var/www/vhosts/Rosita/public/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\Custome...', 'dispatch', Object(Magento\Customer\Controller\Adminhtml\File\Customer\Upload\Interceptor), Array, 'adminAuthentica...')

7 /var/www/vhosts/Rosita/public/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain{closure}(Object(Magento\Framework\App\Request\Http))

8 /var/www/vhosts/Rosita/public/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(Object(Magento\Customer\Controller\Adminhtml\File\Customer\Upload\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))

9 /var/www/vhosts/Rosita/public/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\Custome...', 'dispatch', Object(Magento\Customer\Controller\Adminhtml\File\Customer\Upload\Interceptor), Array, 'adminMassaction...')

10 /var/www/vhosts/Rosita/public/vendor/magento/module-backend/App/Action/Plugin/MassactionKey.php(33): Magento\Customer\Controller\Adminhtml\File\Customer\Upload\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Request\Http))

11 /var/www/vhosts/Rosita/public/vendor/magento/framework/Interception/Interceptor.php(142): Magento\Backend\App\Action\Plugin\MassactionKey->aroundDispatch(Object(Magento\Customer\Controller\Adminhtml\File\Customer\Upload\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))

12 /var/www/vhosts/Rosita/public/var/generation/Magento/Customer/Controller/Adminhtml/File/Customer/Upload/Interceptor.php(26): Magento\Customer\Controller\Adminhtml\File\Customer\Upload\Interceptor->___callPlugins('dispatch', Array, Array)

13 /var/www/vhosts/Rosita/public/vendor/magento/framework/App/FrontController.php(55): Magento\Customer\Controller\Adminhtml\File\Customer\Upload\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))

14 /var/www/vhosts/Rosita/public/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))

15 /var/www/vhosts/Rosita/public/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)

16 /var/www/vhosts/Rosita/public/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'install')

17 /var/www/vhosts/Rosita/public/vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Request\Http))

18 /var/www/vhosts/Rosita/public/vendor/magento/framework/Interception/Interceptor.php(142): Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))

19 /var/www/vhosts/Rosita/public/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)

20 /var/www/vhosts/Rosita/public/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))

21 /var/www/vhosts/Rosita/public/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()

22 /var/www/vhosts/Rosita/public/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))

23 {main} [] []

In vendor/magento/module-customer/Model/FileProcessor.php line 199 there is unset($result['path']);
This is required by the upload function in vendor/magento/module-customer/Model/FileUploader.php

commenting out line 199 results in the file appearing in the customer form, however clicking the link results in a 404 error

Fixed in 2.2.x Fixed in 2.3.x Clear Description Format is valid Reproduced on 2.2.x

Most helpful comment

Hi @stevenlavine. Thank you for your report.
The issue has been fixed in magento/magento2#13563 by @Mkennethsmith in 2.2-develop branch
Related commit(s):

  • 6cc8bdb5bb35acb156bfc8eadc58c51a1d9d8d76
  • 54254ad4b9332b4da4aa0f5b25d598f4f265b670

The fix will be available with the upcoming 2.2.4 release.

All 12 comments

This issue seems to be introduced with this line:
https://github.com/magento/magento2/commit/09d662e2a163049d7d09c8e23e60a547a4b0400a#diff-cd95dedce531a403edab860781af87aeR232

Hi @stevenlavine
How did you create the file upload attribute? Please share install script that add the attribute.
And please could you share a code, that introduce this attribute in to CMS (xml or/and phtml files)

Here is the UpgradeData.php The file attribute is defined on line 109.

UpgradeData.php.txt

@stevenlavine Thanks for the answer.
But for reproduce the issue i need know how do you introduce this attribute in to CMS.

Here is the extension code

Customer.zip

Hi @stevenlavine
After add your module, the "customer file upload attribute" can't appear in customer information CMS.
http://prntscr.com/gw3c35
http://prntscr.com/gw3cpk
http://prntscr.com/gw3cxf
http://prntscr.com/gw3can
Please describe all steps to reproduce the issue

@stevenlavine we are closing this issue due to inactivity. If you'd like to update it, please reopen the issue.

These issues still exist on Magento 2.2.2, if I add customer attributes type "file" or "image", when I save customer information the system will throw an error:
_main.CRITICAL: Exception: Notice: Undefined index: path in vendor/magento/module-customer/Model/FileUploader.php on line 113_

There seems to be a mismatch on the versions this fix is claiming to be applied. The branch the fix was applied to is in 2.3-develop, however the latest comment from @okorshenko states it was fixed in 2.2.x?

Hi @stevenlavine. Thank you for your report.
The issue has been fixed in magento/magento2#13563 by @Mkennethsmith in 2.2-develop branch
Related commit(s):

  • 6cc8bdb5bb35acb156bfc8eadc58c51a1d9d8d76
  • 54254ad4b9332b4da4aa0f5b25d598f4f265b670

The fix will be available with the upcoming 2.2.4 release.

I try with override file but get some issue like under as is any one know about how to solve please share it
main.CRITICAL: Notice: Undefined index: extension in /var/www/html/magentoextension/vendor/magento/framework/File/Uploader.php on line 595 {"exception":"[object] (Exception(code: 0): Notice: Undefined index: extension in /var/www/html/magentoextension/vendor/magento/framework/File/Uploader.php on line 595 at /var/www/html/magentoextension/vendor/magento/framework/App/ErrorHandler.php:61)"} []

i have fixed this issue. for this i need to use preference in di file and copy the code in our new file. for more discussion please join on skype avinash.garg1991

Was this page helpful?
0 / 5 - 0 ratings