6

I want to upload image file. When I click browse button. the browser window show all files.I want only image file.I tried this link https://stackoverflow.com/questions/16832255/show-only-image-files-in-input-type-file-browse-window

When I click browse button, the below browser window appears,

enter image description here

How to fix this...

  • it's not possible my friend – Keyul Shah Jun 21 '14 at 5:32
  • but in backend, when adding product images,it shows only image file.Please check – saravanavelu Jun 21 '14 at 5:36
  • give me some time I will check and let you know – Keyul Shah Jun 21 '14 at 5:40
  • They have using Flash Uploader in Magneto – Keyul Shah Jun 21 '14 at 5:45
1

You can specify the types if your block is initializing proper parent block classes:

$this->getConfig()->setFilters(array(
    'images' => array(
        'label' => Mage::helper('adminhtml')->__('Images (.gif, .jpg, .png)'),
        'files' => array('*.gif', '*.jpg', '*.png')
    ),
    'media' => array(
        'label' => Mage::helper('adminhtml')->__('Media (.avi, .flv, .swf)'),
        'files' => array('*.avi', '*.flv', '*.swf')
    ),
    'all'    => array(
        'label' => Mage::helper('adminhtml')->__('All Files'),
        'files' => array('*.*')
    )
));

Also take note Magento by default uses Flash (Adobe FLEX) for the uploading process, If this is disabled than the alternative methods would need to be considered.

Here is a snippet of the FLEX initilization JS Object. Note the loop of config filters and addTypeFilter:

    handleBridgeInit: function() {
        this.uploader = this.flex.getBridge().getUpload();
        if (this.config.filters) {
            $H(this.config.filters).each(function(pair) {
                this.uploader.addTypeFilter(pair.key, pair.value.label, pair.value.files);
            }.bind(this));
            delete(this.config.filters);
            this.uploader.setUseTypeFilter(true);
        }

Further Reading:

  • How it can be integrate with custom admin form? – saravanavelu Jul 30 '15 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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