43

I follow this steps to add UI fileuploader component in admin form I use UI fileuploader component to upload an icon for my FAQ extension. You can take reference from here: https://github.com/mageprince/magento2-FAQ 1) Add field in admin_form.xml(Admin Form) <field name="icon"> <argument name="data" xsi:type="array"&...


22

If your var/importexportxxx file is blank try; php bin/magento queue:consumers:start exportProcessor https://github.com/magento/magento2/issues/23450


19

In your controller file that $postUrl points to: protected $csv; public function __construct( \Magento\Framework\File\Csv $csv ) { $this->csv = $csv; } //The function name should match your controller path public function import($file) { if (!isset($file['tmp_name'])) throw new \Magento\Framework\Exception\LocalizedException(__('...


13

It was my bad !! I forgot to add enctype'=>'multipart/form-data You have to add following code while creating formFactory $form = $this->_formFactory->create( ['data' => ['id' => 'edit_form', 'enctype'=>'multipart/form-data','action' => $this->getData('action'), 'method' => 'post']] );


11

You have to run cron by command line as mentioned here: php bin/magento cron:run https://github.com/magento/magento2/issues/23450#issuecomment-507581035 Then refresh the export page and you should see the file at the bottom.


7

This is caused by a bug in magento 2.3.0, which will be fixed in 2.3.1 release. You obviously cannot wait until then and you definitely don't want to edit core files. ref: https://github.com/magento/magento2/issues/18688 If you use composer to install/update magento 2.3.0 (if you don't, you should), you can apply a patch to the code via composer. The ...


6

bool mkdir ( string $pathname [, int $mode = 0777 [, bool $recursive = false [, resource $context ]]] ) $pathname should be the server path to the file and not a url Try $path = Mage::getBaseDir('media') . DS; You should try using Varien_File_Uploader /* Starting upload */ $uploader = new Varien_File_Uploader('filename'); // Any extention would work $...


6

Ok, I got it working with this: $this->getRequest()->getFiles('slide')['image']


6

Supplement for Magento 2.2 UI component Compare with Magento 2.1, in Magento 2.2, the UI component had some optional differences like below. We could make use of the official Magento_Catalog/image-preview as preview templete, and the rest of codes like controller could refer to the accepted answer. <field name="image" formElement="fileUploader"> &...


6

The method $uploader->save($target); has a second parameter: string $newFileName Also you'll find the method $uploader->getUploadedFileName() to get the filename. You can use strpos() to find the string in the file name. I hope it helps you.


6

Please replace your UI Component with following code. Change imageUploader instead of fileUploader in your formElement. <field name="ffl"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="dataType" xsi:type="string">string</item> ...


5

I think there is no Default setting in code: Just update php.ini settings: memory_limit = 32M upload_max_filesize = 24M post_max_size = 32M Hope this will work!!


5

this will help $files = $this->getRequest()->getFiles(); Here is Magento2 :: Accessing $_FILES using Magento Framework


5

You can create a custom extension (let custom extension name is "Vendor_MyModule") for Front-end image uploading. I assume you already created the custom extension "Vendor_MyModule". So I am describing here only the necessary files related to image uploading operation. Please follow below steps . step 1: Create the uploader model file. ...


5

As per Magento 2 coding standard you should use magento function instead of direct php functions You can use isReadable() function of class Magento\Framework\Filesystem\Driver\File Also available other function like use fileGetCsv() for fgetcsv() use fileOpen() for fopen() You can find more file specific functions from vendor/magento/framework/...


5

This is the fix for this issue vendor/magento/module-email/view/adminhtml/ui_component/design_config_form.xml <collapsible>true</collapsible> <label translate="true">Transactional Emails</label> </settings> - <field name="email_logo" formElement="fileUploader"> + <field name="email_logo" ...


4

We had the same issue but a little search in the core and also this link helped us figure out the solution you've to use $uploader = $this->_objectManager->create( 'Magento\MediaStorage\Model\File\Uploader', ['fileId' => 'my_file_uploader'] ); in place of $_FILES and it's much better like this, you can access various methods in the object. ...


4

I wasn't able to view the buttons last week. It was because Flash hadn't been updated. So I suggest you make sure Flash is up-to-date first. Other suggestions: You could try restarting the browser Or in the php.ini file change upload_max_filesize = 100 M to upload_max_filesize = 100M, (no space) or Check if .gitignore is referencing media/ instead of /...


4

You can pass your custom file name in save function as second argument. If you check vendor\magento\framework\File\Uploader.php::save($destinationFolder, $newFileName = null) You find second argument is the new file name with which you want to save. All you have to do is $uploader->save($destinationPath,YOUR_RANDOM_FILENAME); And your file will be ...


4

There're 2 possible ways to solve this. You can either opt to update the component, and thus get an access to it. Or, you can use your own element that extends the standard Magento_Ui/js/form/element/file-uploader. In the example below, we'll describe the second option, as it's more flexible and easier to implement. Create a file: app/code/Vendor/...


4

This error can be caused by server permissions / configurations. It could simply be a permission issue so please ensure your web server user has full rights as per it's recommended in devdocs http://bit.ly/2v325mQ. If that doesn't resolve the issue then you may want to look at the file size and see it's not larger than the allowed file size on your server.


4

This will resolve the problem. Put this in controller. $files = $this->getRequest()->getFiles() Here is Magento2 :: Accessing $_FILES using Magento Framework


4

You can use Magento\Framework\Filesystem\Io\File instead. Example: <?php namespace Vendor\ModuleName\Model; use Magento\Framework\Filesystem\Io\File; class MyClass { /** * @var File */ private $file; /** * @param File $file */ public function __construct(File $file) { $this->file = $file; } public ...


4

use Magento\MediaStorage\Model\File\UploaderFactory; protected $uploaderFactory; public function __construct( ... UploaderFactory $uploaderFactory .... ) { .... $this->uploaderFactory = $uploaderFactory; .... } $uploader = $this->uploaderFactory->create(['fileId' => $fileId]); $uploader->...


4

This it the controller file to save/read imported CSV data: <?php namespace VendorName\ModuleName\Controller\Adminhtml\Pincode\Import; use Magento\Framework\App\Filesystem\DirectoryList; class Save extends \Magento\Backend\App\Action { /** * Authorization level of a basic admin session * * @see _isAllowed() */ const ...


4

Didn't test this, but I think $result = $this->imageUploader->upload('slide'); should be $result = $this->imageUploader->upload('image'); //use the name of the field not of the fieldset. Also add this inside the <item name="config" xsi:type="array"> element <item name="dataScope" xsi:type="string">image</item>


4

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];...


3

MDNsolutions did a blog post about this. It will enable PDF upload via the media gallery. I've used it before but on an older shop so I can't guarantee it'll work in a later version of Magento If that doesn't work, have a look at this post. It explains how to create a widget that accepts an image but might also work for PDF.


3

First get saved file string from model and save it to one variable if ($id) { $model->load($id); $uploadedFile = $model->getFile(); // Get already uploded file path } Now pass it into your helper function $imageFile = $this->helper->uploadFile('file', $uploadedFile); $model->setFile($imageFile); Now in helper function remove throw ...


3

You can upload using at \Magento\MediaStorage\Model\File\UploaderFactory. protected $_mediaDirectory; protected $_fileUploaderFactory; public function __construct( Context $context, \Magento\Framework\Filesystem $filesystem, \Magento\MediaStorage\Model\File\UploaderFactory $fileUploaderFactory ) { $this->_mediaDirectory = $...


Only top voted, non community-wiki answers of a minimum length are eligible