ReferenceError: Uploader is not defined in magento 1.9.3
-
03-10-2020 - |
Pregunta
after update to new version 1.9.3. the Uploader is not working anymore. given below error.i upldate my code but still the same.
var uploader = new
Uploader({"uploaderConfig":{"chunkSize":1073741824,"withCrede...
below is my code
class Spacename_Modulename_Block_Adminhtml_Modulename_Edit_Tab_Images extends Mage_Adminhtml_Block_Widget {
protected $_uploaderType = 'uploader/multiple';
protected function _prepareForm() {
$data = $this->getRequest()->getPost();
$form = new Varien_Data_Form();
$form->setValues($data);
$this->setForm($form);
return parent::_prepareForm();
}
protected function _prepareLayout() {
$this->setChild('uploader', $this->getLayout()->createBlock($this->_uploaderType)
);
$this->getUploader()->getUploaderConfig()
->setFileParameterName('image')
->setTarget(Mage::getModel('adminhtml/url')->addSessionParam()->getUrl('*/*/image'));
$browseConfig = $this->getUploader()->getButtonConfig();
$browseConfig
->setAttributes(array(
'accept' => $browseConfig->getMimeTypesByExtensions('gif, png, jpeg, jpg')
));
return parent::_prepareLayout();
}
}
js code
<script type="text/javascript">
//<![CDATA[
var <?php echo $_block->getJsObjectName(); ?> = new Product.Gallery('<?php echo $_block->getHtmlId() ?>', <?php echo $_block->getImageTypesJson() ?>);
//]]>
</script>
Solución
After lot of searching i found that magento 1.9.3.0 they remove the flash uploader so js file need to run uploader add these file in head
<reference name="head">
<action method="addJs"><file>lib/uploader/flow.min.js</file></action>
<action method="addJs"><file>lib/uploader/fusty-flow.js</file></action>
<action method="addJs"><file>lib/uploader/fusty-flow-factory.js</file></action>
<action method="addJs"><file>mage/adminhtml/uploader/instance.js</file></action>
</reference>
Otros consejos
I solved this problem by adjusting the file permissions.
Problem was that the above mentioned (new) Javascript files could not be loaded. A 403 error code has been thrown.
After setting file permissions on the directories
js/image/adminhtml/uploader
and
js/lib/uploader,
the upload button works correctly again!
Whereabouts are we supposed to add:
<reference name="head">
<action method="addJs"><file>lib/uploader/flow.min.js</file></action>
<action method="addJs"><file>lib/uploader/fusty-flow.js</file></action>
<action method="addJs"><file>lib/uploader/fusty-flow-factory.js</file></action>
<action method="addJs"><file>mage/adminhtml/uploader/instance.js</file></action>
</reference>
I'm not sure what you mean by head