- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2018
09:44 PM
10-14-2018
09:44 PM
Recoger los datos de un input de tipo file
Hola a todos, estoy teniendo problemas con un formulario que contiene un input de tipo file, resulta que el formulario contiene unos input de tipo, text, email y file, que son mandados por POST y AJAX a un controllador, ese controllador recoge perfectamente los input de tipo text, email y demás menos el de tipo file.
os adjunto la el código del controllador por si véis algo que yo no he visto.
/** @var TYPE_NAME $post */ $post = $this->getRequest()->getPost(); $filesData = $this->getRequest()->getFiles()('uploadfile'); /** @var TYPE_NAME $filesData */ if (!empty($filesData)) { $uploader = $this->_fileUploaderFactory->create(['fileId' => 'uploadfile']); $uploader->setAllowRenameFiles(true); $uploader->setAllowCreateFolders(true); $uploader->setFilesDispersion(true); $uploader->setAllowedExtensions(['jpg', 'jpeg', 'png', 'gif']); $mediaDirectory = $this->_fileSystem->getDirectoryRead(DirectoryList::MEDIA)->getAbsolutePath('pedidos_de_prueba/'); $result = $uploader->save($mediaDirectory); $uploadFile = 'pedidos_de_prueba/' . $uploader->getUploadedFilename(); $filePath = $result['path'] . $result['file']; $fileName = $result['name']; } else { $uploadFile = 'http://miweb.test/'; $filePath = 'media/'; $fileName = 'imagen.jpg'; }
Espero que podáis ayudarme.
Gracias.
Desarrollador Front-End