51 lines
1.6 KiB
PHP
Raw Normal View History

2017-06-23 17:07:55 +02:00
<?php
require_once dirname(__FILE__).'/../../classes/UploadHandler.php';
class AntadisConfiguratorUploadModuleFrontController extends ModuleFrontController
{
public function init()
{
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ) {
$this->ajax = true;
}
}
public function postProcess()
{
error_reporting(E_ALL | E_STRICT);
$id_product = Tools::getValue('id_product');
$reference = Tools::getValue('reference');
2017-07-20 14:28:43 +02:00
$delete = Tools::getValue('del', 0);
if ($delete == 1) {
$filename = Tools::getValue('q');
$path = _PS_UPLOAD_DIR_.$id_product.'/'.$reference.'/'.$filename;
if(file_exists($path) && is_file($path)) {
if (unlink($path)) {
echo Tools::jsonEncode(array('delete' => 1));
exit;
}
}
echo Tools::jsonEncode(array('delete' => 0));
exit;
}
2017-08-07 10:40:32 +02:00
$path = _PS_UPLOAD_DIR_.'simu/'.$id_product.'/'.$reference;
2017-06-23 17:07:55 +02:00
if(!file_exists($path)) {
mkdir($path, null, true);
}
2017-08-07 10:40:32 +02:00
$url = _PS_BASE_URL_.'/upload/simu/'.$id_product.'/'.$reference;
2017-06-23 17:07:55 +02:00
$options = array(
'upload_dir' => $path.'/',
'upload_url' => $url.'/',
2017-06-26 15:36:19 +02:00
'image_versions' => array(), //disable thumbnail generation
2017-06-23 17:07:55 +02:00
);
2017-06-26 15:36:19 +02:00
2017-06-23 17:07:55 +02:00
$upHandler = new UploadHandler($options);
exit;
}
}