38 lines
1.0 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);
2017-06-26 12:13:19 +02:00
2017-06-23 17:07:55 +02:00
// Nom de l'image uniqid()
$id_product = Tools::getValue('id_product');
$reference = Tools::getValue('reference');
$path = _PS_UPLOAD_DIR_.$id_product.'/'.$reference;
if(!file_exists($path)) {
mkdir($path, null, true);
}
$url = _PS_BASE_URL_.'/upload/'.$id_product.'/'.$reference;
$options = array(
'upload_dir' => $path.'/',
'upload_url' => $url.'/',
);
$upHandler = new UploadHandler($options);
exit;
}
}