Customer attribute with Image upload throwing error





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I've created one customer attribute with input type, Check below code for reference.



public function install(
ModuleDataSetupInterface $setup,
ModuleContextInterface $context
) {
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
$setup->startSetup();
$attributesInfo = [
'upload_documents' => [
'label' => 'Upload Document',
'type' => 'varchar',
'input' => 'image',
'position' => 1000,
'visible' => true,
'required' => false,
'system' => 0,
'user_defined' => true,
"source" => 'MagentoEavModelEntityAttributeSourceTable',
'position' => 1000,
'is_used_in_grid' => true,
'is_visible_in_grid' => true,
'is_html_allowed_on_front' => true,
'visible_on_front' => true
]
];
$customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
$attributeSetId = $customerEntity->getDefaultAttributeSetId();
/** @var $attributeSet AttributeSet */
$attributeSet = $this->attributeSetFactory->create();
$attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);
foreach ($attributesInfo as $attributeCode => $attributeParams) {
$customerSetup->addAttribute(Customer::ENTITY, $attributeCode, $attributeParams);
}
$magentoUsernameAttribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'upload_documents');
$magentoUsernameAttribute->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer','customer_account_edit','adminhtml_checkout','adminhtml_customer_address','customer_address_edit','customer_register_address'],
]);
$magentoUsernameAttribute->save();

$setup->endSetup();


This is working fine, I can upload image from registration form. Its working with all image type but when I upload PDF it also working it display's PDF at backend.



Issue happens when I try to save customer which has PDF document its shows me error.



"Upload Document" is not a valid image format



Also after I can't upload PDF files from backend too.



Does anyone has what is I'm missing here ?? Any help would be appreciated.










share|improve this question





























    0















    I've created one customer attribute with input type, Check below code for reference.



    public function install(
    ModuleDataSetupInterface $setup,
    ModuleContextInterface $context
    ) {
    $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
    $setup->startSetup();
    $attributesInfo = [
    'upload_documents' => [
    'label' => 'Upload Document',
    'type' => 'varchar',
    'input' => 'image',
    'position' => 1000,
    'visible' => true,
    'required' => false,
    'system' => 0,
    'user_defined' => true,
    "source" => 'MagentoEavModelEntityAttributeSourceTable',
    'position' => 1000,
    'is_used_in_grid' => true,
    'is_visible_in_grid' => true,
    'is_html_allowed_on_front' => true,
    'visible_on_front' => true
    ]
    ];
    $customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
    $attributeSetId = $customerEntity->getDefaultAttributeSetId();
    /** @var $attributeSet AttributeSet */
    $attributeSet = $this->attributeSetFactory->create();
    $attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);
    foreach ($attributesInfo as $attributeCode => $attributeParams) {
    $customerSetup->addAttribute(Customer::ENTITY, $attributeCode, $attributeParams);
    }
    $magentoUsernameAttribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'upload_documents');
    $magentoUsernameAttribute->addData([
    'attribute_set_id' => $attributeSetId,
    'attribute_group_id' => $attributeGroupId,
    'used_in_forms' => ['adminhtml_customer','customer_account_edit','adminhtml_checkout','adminhtml_customer_address','customer_address_edit','customer_register_address'],
    ]);
    $magentoUsernameAttribute->save();

    $setup->endSetup();


    This is working fine, I can upload image from registration form. Its working with all image type but when I upload PDF it also working it display's PDF at backend.



    Issue happens when I try to save customer which has PDF document its shows me error.



    "Upload Document" is not a valid image format



    Also after I can't upload PDF files from backend too.



    Does anyone has what is I'm missing here ?? Any help would be appreciated.










    share|improve this question

























      0












      0








      0








      I've created one customer attribute with input type, Check below code for reference.



      public function install(
      ModuleDataSetupInterface $setup,
      ModuleContextInterface $context
      ) {
      $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
      $setup->startSetup();
      $attributesInfo = [
      'upload_documents' => [
      'label' => 'Upload Document',
      'type' => 'varchar',
      'input' => 'image',
      'position' => 1000,
      'visible' => true,
      'required' => false,
      'system' => 0,
      'user_defined' => true,
      "source" => 'MagentoEavModelEntityAttributeSourceTable',
      'position' => 1000,
      'is_used_in_grid' => true,
      'is_visible_in_grid' => true,
      'is_html_allowed_on_front' => true,
      'visible_on_front' => true
      ]
      ];
      $customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
      $attributeSetId = $customerEntity->getDefaultAttributeSetId();
      /** @var $attributeSet AttributeSet */
      $attributeSet = $this->attributeSetFactory->create();
      $attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);
      foreach ($attributesInfo as $attributeCode => $attributeParams) {
      $customerSetup->addAttribute(Customer::ENTITY, $attributeCode, $attributeParams);
      }
      $magentoUsernameAttribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'upload_documents');
      $magentoUsernameAttribute->addData([
      'attribute_set_id' => $attributeSetId,
      'attribute_group_id' => $attributeGroupId,
      'used_in_forms' => ['adminhtml_customer','customer_account_edit','adminhtml_checkout','adminhtml_customer_address','customer_address_edit','customer_register_address'],
      ]);
      $magentoUsernameAttribute->save();

      $setup->endSetup();


      This is working fine, I can upload image from registration form. Its working with all image type but when I upload PDF it also working it display's PDF at backend.



      Issue happens when I try to save customer which has PDF document its shows me error.



      "Upload Document" is not a valid image format



      Also after I can't upload PDF files from backend too.



      Does anyone has what is I'm missing here ?? Any help would be appreciated.










      share|improve this question














      I've created one customer attribute with input type, Check below code for reference.



      public function install(
      ModuleDataSetupInterface $setup,
      ModuleContextInterface $context
      ) {
      $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
      $setup->startSetup();
      $attributesInfo = [
      'upload_documents' => [
      'label' => 'Upload Document',
      'type' => 'varchar',
      'input' => 'image',
      'position' => 1000,
      'visible' => true,
      'required' => false,
      'system' => 0,
      'user_defined' => true,
      "source" => 'MagentoEavModelEntityAttributeSourceTable',
      'position' => 1000,
      'is_used_in_grid' => true,
      'is_visible_in_grid' => true,
      'is_html_allowed_on_front' => true,
      'visible_on_front' => true
      ]
      ];
      $customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
      $attributeSetId = $customerEntity->getDefaultAttributeSetId();
      /** @var $attributeSet AttributeSet */
      $attributeSet = $this->attributeSetFactory->create();
      $attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);
      foreach ($attributesInfo as $attributeCode => $attributeParams) {
      $customerSetup->addAttribute(Customer::ENTITY, $attributeCode, $attributeParams);
      }
      $magentoUsernameAttribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'upload_documents');
      $magentoUsernameAttribute->addData([
      'attribute_set_id' => $attributeSetId,
      'attribute_group_id' => $attributeGroupId,
      'used_in_forms' => ['adminhtml_customer','customer_account_edit','adminhtml_checkout','adminhtml_customer_address','customer_address_edit','customer_register_address'],
      ]);
      $magentoUsernameAttribute->save();

      $setup->endSetup();


      This is working fine, I can upload image from registration form. Its working with all image type but when I upload PDF it also working it display's PDF at backend.



      Issue happens when I try to save customer which has PDF document its shows me error.



      "Upload Document" is not a valid image format



      Also after I can't upload PDF files from backend too.



      Does anyone has what is I'm missing here ?? Any help would be appreciated.







      magento2 customer-attribute






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 11 hours ago









      VivekVivek

      1,5921632




      1,5921632






















          1 Answer
          1






          active

          oldest

          votes


















          0














          By default magento does not allow PDF format on upload to make this an option you will need to create a basic extension and include



          app/code/CustomVendor/CustomModule/etc/di.xml



          <?xml version="1.0"?>
          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
          <type name="MagentoCmsModelWysiwygImagesStorage">
          <arguments>
          <argument name="resizeParameters" xsi:type="array">
          <item name="height" xsi:type="number">75</item>
          <item name="width" xsi:type="number">100</item>
          </argument>
          <argument name="extensions" xsi:type="array">
          <item name="allowed" xsi:type="array">
          <item name="jpg" xsi:type="number">1</item>
          <item name="jpeg" xsi:type="number">1</item>
          <item name="png" xsi:type="number">1</item>
          <item name="gif" xsi:type="number">1</item>
          <item name="pdf" xsi:type="number">1</item>
          </item>
          <item name="image_allowed" xsi:type="array">
          <item name="jpg" xsi:type="number">1</item>
          <item name="jpeg" xsi:type="number">1</item>
          <item name="png" xsi:type="number">1</item>
          <item name="gif" xsi:type="number">1</item>
          </item>
          <item name="media_allowed" xsi:type="array">
          <item name="flv" xsi:type="number">1</item>
          <item name="swf" xsi:type="number">1</item>
          <item name="avi" xsi:type="number">1</item>
          <item name="mov" xsi:type="number">1</item>
          <item name="rm" xsi:type="number">1</item>
          <item name="wmv" xsi:type="number">1</item>
          <item name="pdf" xsi:type="number">1</item>
          </item>
          </argument>
          <argument name="dirs" xsi:type="array">
          <item name="exclude" xsi:type="string"/>
          <item name="include" xsi:type="string"/>
          </argument>
          </arguments>
          </type>
          </config>





          share|improve this answer
























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "479"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f269921%2fcustomer-attribute-with-image-upload-throwing-error%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            By default magento does not allow PDF format on upload to make this an option you will need to create a basic extension and include



            app/code/CustomVendor/CustomModule/etc/di.xml



            <?xml version="1.0"?>
            <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
            <type name="MagentoCmsModelWysiwygImagesStorage">
            <arguments>
            <argument name="resizeParameters" xsi:type="array">
            <item name="height" xsi:type="number">75</item>
            <item name="width" xsi:type="number">100</item>
            </argument>
            <argument name="extensions" xsi:type="array">
            <item name="allowed" xsi:type="array">
            <item name="jpg" xsi:type="number">1</item>
            <item name="jpeg" xsi:type="number">1</item>
            <item name="png" xsi:type="number">1</item>
            <item name="gif" xsi:type="number">1</item>
            <item name="pdf" xsi:type="number">1</item>
            </item>
            <item name="image_allowed" xsi:type="array">
            <item name="jpg" xsi:type="number">1</item>
            <item name="jpeg" xsi:type="number">1</item>
            <item name="png" xsi:type="number">1</item>
            <item name="gif" xsi:type="number">1</item>
            </item>
            <item name="media_allowed" xsi:type="array">
            <item name="flv" xsi:type="number">1</item>
            <item name="swf" xsi:type="number">1</item>
            <item name="avi" xsi:type="number">1</item>
            <item name="mov" xsi:type="number">1</item>
            <item name="rm" xsi:type="number">1</item>
            <item name="wmv" xsi:type="number">1</item>
            <item name="pdf" xsi:type="number">1</item>
            </item>
            </argument>
            <argument name="dirs" xsi:type="array">
            <item name="exclude" xsi:type="string"/>
            <item name="include" xsi:type="string"/>
            </argument>
            </arguments>
            </type>
            </config>





            share|improve this answer




























              0














              By default magento does not allow PDF format on upload to make this an option you will need to create a basic extension and include



              app/code/CustomVendor/CustomModule/etc/di.xml



              <?xml version="1.0"?>
              <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
              <type name="MagentoCmsModelWysiwygImagesStorage">
              <arguments>
              <argument name="resizeParameters" xsi:type="array">
              <item name="height" xsi:type="number">75</item>
              <item name="width" xsi:type="number">100</item>
              </argument>
              <argument name="extensions" xsi:type="array">
              <item name="allowed" xsi:type="array">
              <item name="jpg" xsi:type="number">1</item>
              <item name="jpeg" xsi:type="number">1</item>
              <item name="png" xsi:type="number">1</item>
              <item name="gif" xsi:type="number">1</item>
              <item name="pdf" xsi:type="number">1</item>
              </item>
              <item name="image_allowed" xsi:type="array">
              <item name="jpg" xsi:type="number">1</item>
              <item name="jpeg" xsi:type="number">1</item>
              <item name="png" xsi:type="number">1</item>
              <item name="gif" xsi:type="number">1</item>
              </item>
              <item name="media_allowed" xsi:type="array">
              <item name="flv" xsi:type="number">1</item>
              <item name="swf" xsi:type="number">1</item>
              <item name="avi" xsi:type="number">1</item>
              <item name="mov" xsi:type="number">1</item>
              <item name="rm" xsi:type="number">1</item>
              <item name="wmv" xsi:type="number">1</item>
              <item name="pdf" xsi:type="number">1</item>
              </item>
              </argument>
              <argument name="dirs" xsi:type="array">
              <item name="exclude" xsi:type="string"/>
              <item name="include" xsi:type="string"/>
              </argument>
              </arguments>
              </type>
              </config>





              share|improve this answer


























                0












                0








                0







                By default magento does not allow PDF format on upload to make this an option you will need to create a basic extension and include



                app/code/CustomVendor/CustomModule/etc/di.xml



                <?xml version="1.0"?>
                <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
                <type name="MagentoCmsModelWysiwygImagesStorage">
                <arguments>
                <argument name="resizeParameters" xsi:type="array">
                <item name="height" xsi:type="number">75</item>
                <item name="width" xsi:type="number">100</item>
                </argument>
                <argument name="extensions" xsi:type="array">
                <item name="allowed" xsi:type="array">
                <item name="jpg" xsi:type="number">1</item>
                <item name="jpeg" xsi:type="number">1</item>
                <item name="png" xsi:type="number">1</item>
                <item name="gif" xsi:type="number">1</item>
                <item name="pdf" xsi:type="number">1</item>
                </item>
                <item name="image_allowed" xsi:type="array">
                <item name="jpg" xsi:type="number">1</item>
                <item name="jpeg" xsi:type="number">1</item>
                <item name="png" xsi:type="number">1</item>
                <item name="gif" xsi:type="number">1</item>
                </item>
                <item name="media_allowed" xsi:type="array">
                <item name="flv" xsi:type="number">1</item>
                <item name="swf" xsi:type="number">1</item>
                <item name="avi" xsi:type="number">1</item>
                <item name="mov" xsi:type="number">1</item>
                <item name="rm" xsi:type="number">1</item>
                <item name="wmv" xsi:type="number">1</item>
                <item name="pdf" xsi:type="number">1</item>
                </item>
                </argument>
                <argument name="dirs" xsi:type="array">
                <item name="exclude" xsi:type="string"/>
                <item name="include" xsi:type="string"/>
                </argument>
                </arguments>
                </type>
                </config>





                share|improve this answer













                By default magento does not allow PDF format on upload to make this an option you will need to create a basic extension and include



                app/code/CustomVendor/CustomModule/etc/di.xml



                <?xml version="1.0"?>
                <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
                <type name="MagentoCmsModelWysiwygImagesStorage">
                <arguments>
                <argument name="resizeParameters" xsi:type="array">
                <item name="height" xsi:type="number">75</item>
                <item name="width" xsi:type="number">100</item>
                </argument>
                <argument name="extensions" xsi:type="array">
                <item name="allowed" xsi:type="array">
                <item name="jpg" xsi:type="number">1</item>
                <item name="jpeg" xsi:type="number">1</item>
                <item name="png" xsi:type="number">1</item>
                <item name="gif" xsi:type="number">1</item>
                <item name="pdf" xsi:type="number">1</item>
                </item>
                <item name="image_allowed" xsi:type="array">
                <item name="jpg" xsi:type="number">1</item>
                <item name="jpeg" xsi:type="number">1</item>
                <item name="png" xsi:type="number">1</item>
                <item name="gif" xsi:type="number">1</item>
                </item>
                <item name="media_allowed" xsi:type="array">
                <item name="flv" xsi:type="number">1</item>
                <item name="swf" xsi:type="number">1</item>
                <item name="avi" xsi:type="number">1</item>
                <item name="mov" xsi:type="number">1</item>
                <item name="rm" xsi:type="number">1</item>
                <item name="wmv" xsi:type="number">1</item>
                <item name="pdf" xsi:type="number">1</item>
                </item>
                </argument>
                <argument name="dirs" xsi:type="array">
                <item name="exclude" xsi:type="string"/>
                <item name="include" xsi:type="string"/>
                </argument>
                </arguments>
                </type>
                </config>






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 10 hours ago









                Dava GordonDava Gordon

                61029




                61029






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Magento Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f269921%2fcustomer-attribute-with-image-upload-throwing-error%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    What other Star Trek series did the main TNG cast show up in?

                    Berlina muro

                    Berlina aerponto