Argument 1 passed to App\Service\FileUploader::upload() must be an instance – symfony 4

If you face “Argument 1 passed to App\Service\FileUploader::upload() must be an instance of Symfony\Component\HttpFoundation\File\UploadedFile, string given, ” this error while playing with files in Symfony 4. Then you need to change your file field in controller as. Change your code from

$file = $task->getTaskLogo(); 
to
$file = $form['task_logo']->getData();
. Where task_logo is the name of the file field of your form.

 

 

 

 

Points to keep in mind while developing custom form in Magento 2 module on admin end.

Two things keep in mind


1) Form action could be defined as

<?php echo $this-&gt;getUrl("pilot_smile/options/save"); ?>;
2) Do not forget to add form_key else you would be going to waste your several hours on finding the dashboard redirection issue on form submission.
<input name="form_key" type="hidden" value="<?php echo $block->getFormKey()?>" />;