51 lines
1.6 KiB
PHP
51 lines
1.6 KiB
PHP
<?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');
|
|
|
|
$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;
|
|
}
|
|
|
|
$path = _PS_UPLOAD_DIR_.'simu/'.$id_product.'/'.$reference;
|
|
if(!file_exists($path)) {
|
|
mkdir($path, null, true);
|
|
}
|
|
$url = _PS_BASE_URL_.'/upload/simu/'.$id_product.'/'.$reference;
|
|
|
|
$options = array(
|
|
'upload_dir' => $path.'/',
|
|
'upload_url' => $url.'/',
|
|
'image_versions' => array(), //disable thumbnail generation
|
|
);
|
|
|
|
$upHandler = new UploadHandler($options);
|
|
|
|
exit;
|
|
}
|
|
} |