I am trying to move the uploaded image to a folder by a custom module.
In /var/www/html/magento16f/app/code/local/Custommodule/ReviewRating/controllers/IndexController.php
public function move_uploadedFileAction( ) {
Mage::log($_FILES);
$path = Mage::getBaseDir() . '/uploadfolder';
Mage::log( $path );
if (!file_exists($path)) {
mkdir($path, 777, true);
}
try {
$fname = $_FILES['unverified-images']['name'];
$uploader = new Varien_File_Uploader('unverified-images');
$uploader->setAllowedExtensions(array('png', 'gif', 'jpeg', 'docx'));
$uploader->setAllowCreateFolders(true);
$uploader->setAllowRenameFiles(false);
$uploader->setFilesDispersion(false);
$uploader->save($path, $fname);
Mage::log( $uploader );
} catch (Exception $e) {
echo 'Error Message: ' . $e->getMessage();
}
$this->_redirectReferer();
}
In /var/www/html/magento16f/app/design/frontend/base/default/template/reviewrating/signupformhb.phtml
''''''''''''''''''''''
<input type="file" multiple="multiple" name="unverified-images" value="Upload" />
'''''''''''''''''''''''''
This function calls a js function which trigger some api on sussess of api return i want to move the uploaded images to a folder and then share the link.
In js file i call below function
function write_review() {
var form = document.getElementById('hb_writereview_user');
var url = "http://somewebsite.com?api";
var params = form.serialize();
httpRequest (params, url, 'POST', function (response) {
if(response.error) {
document.getElementById('hb_show_message_review').innerHTML=response.message;
} else {
uploadFileHb(params);
}
});
}
In /var/www/html/magento16f/app/design/frontend/base/default/template/reviewrating/signupformhb.phtml
<script type="text/javascript">
//<![CDATA[
function uploadFileHb( myFileObject ) {
var xhr = new XMLHttpRequest();
// Open our connection using the POST method
xhr.open("POST", "<?php echo $this->getUrl('reviewrating/index/move_uploadedFile') ?>");
// Send the file
xhr.send(myFileObject);
}
I am not getting log (Mage::log) from controller