0
$_FILES array is empty

getting this error whenever try to upload an image have tested everything even changing a server and also updated the Magento 2 version but the issue is still the same. Magneto V 2.3.7

1 Answer 1

0

Can you try below code and check,

  1. In your form, add the enctype attribute to the <form> tag:

Here is the code:-

<form action="your/controller/action" method="post" enctype="multipart/form-data">
    <!-- Your form fields go here -->
    <input type="file" name="file_field_name">
    <input type="submit" value="Upload">
</form>
  1. In your controller, use the $_FILES array to retrieve the uploaded file:

Here is the code:-

<?php
namespace YourVendor\Module\Controller\YourController;

use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;

class YourAction extends Action
{
    public function execute()
    {
        $file = $_FILES['file_field_name'];
        // Do something with the uploaded file
    }
}

Let me know if any query.

THANKS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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