$_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
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityCan you try below code and check,
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>
$_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.