2

I had develop one module and it works currectly But When I have check Coding standard using phpcs it will provide me Error in php coding standard

--standard=MEQP2

Error is

enter image description here

i have get result of $_FILES in this format

Array
(
    [dynamic_rows_container] => Array
        (
            [name] => Array
                (
                    [0] => Array
                        (
                            [logo] => BACKGROUNDDEFAULT.jpg
                        )

                )

            [type] => Array
                (
                    [0] => Array
                        (
                            [logo] => image/jpeg
                        )

                )

            [tmp_name] => Array
                (
                    [0] => Array
                        (
                            [logo] => D:\xampp72\tmp\php1E43.tmp
                        )

                )

            [error] => Array
                (
                    [0] => Array
                        (
                            [logo] => 0
                        )

                )

            [size] => Array
                (
                    [0] => Array
                        (
                            [logo] => 120785
                        )

                )

        )

)

and I want in This

Array
(
    [logo] => Array
        (
            [name] => BACKGROUNDDEFAULT.jpg
            [type] => image/jpeg
            [tmp_name] => D:\xampp72\tmp\phpD833.tmp
            [error] => 0
            [size] => 120785
        )

)

and I have use this code to formate file array this is my code

    foreach ($_FILES['dynamic_rows_container'] as $i => $item) {
        foreach ($item as $key => $value) {
            $file['logo'][$i] = $value['logo'];
        }
    }
    $_FILES = $file;

If any one has solution then Provide me. thank u in advance.

  • @magefms This will give the object manager error – Hardik Makwana Apr 24 at 7:50
  • can you post your code on how you get the array in $_FILES – fmsthird Apr 24 at 9:10
  • @magefms i had describe abow – Bhavesh Prajapati Apr 24 at 10:32
  • I mean the whole controller code – fmsthird Apr 24 at 10:33
  • @magefms Pleas check my code which you requested and find any solution – Bhavesh Prajapati Apr 24 at 11:28
2

it works I had Find Solution of it 😀

In Place of

$_FILES

I had use Dynamic Variable

${'_FILES'}

Magento Coding Standard is not Providing any Error or Warning.

Then My Code is

foreach (${'_FILES'}['dynamic_rows_container'] as $i => $item) {
            foreach ($item as $key => $value) {
                $file[$fileId][$i] = $value[$fileId];
            }
        }
        ${'_FILES'} = $file;

My Functionality is Working Fine and Magento Coding Standard is Not Providing any Type of Issue.

Please Guide me My way is Right or Not ...............................

  • Yes,it is worked great for me – Hardik Makwana Apr 27 at 7:00
  • It only makes sniffer notice disappear ... no good solution. I#d llok for Zend classes that deal with file uploads. – sv3n Apr 27 at 19:43
  • @sv3n if you have any right way to Update $_FILES structure and value { i will find another way for this issue } – Bhavesh Prajapati Apr 28 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.