Below is the code, I am new in cs cart and unable to figure out how can I get the ajax call from tpl in php file. I want to implement a file upload feature into the admin panel of cs cart. hooks/order_management/upload_data.tpl `
$(document).ready(function(){
alert("doc ready");
$("#btn_ok").click(function( event ) {
event.preventDefault();
var val = $("#myfile").val();
var data = "data=" + val;
$.ajax({
type: "POST",
url: '../../../app/addons/ugw_upload_form/controllers/backend/order_management.post.php',
data: data,
cache: false,
success: function(response)
{ console.log(response);}
});
});
});
</script>
<div class="control-group">
<input type="text" name="myfile" id="myfile" />
<input type="button" id="btn_ok" name="submit" value="upload" >
</div>`
controller/backend/order_management.post.php
`
if (!defined('BOOTSTRAP')) { die('Access denied'); }
use Tygh\Registry;
Registry::get('view')->assign('test_var', "Test");
Registry::get('view')->assign('uploadhere', "upload the file here");
if(isset($_POST['data'])){
$textvalue = $_POST['data'];
$handle = fopen("Z:\members.txt", "w");
fwrite($handle, $textvalue);
fclose($handle);
}
?>`