Example #1
0
<?php

require_once dirname(__FILE__) . '../../../config/config.inc.php';
require_once dirname(__FILE__) . '../../../init.php';
require_once dirname(__FILE__) . '/simplecategory.php';
$module = new SimpleCategory();
$response = new stdClass();
if (!Tools::isSubmit('secure_key') || Tools::getValue('secure_key') != $module->secure_key) {
    $response->status = 0;
    $response->fileName = "";
    $response->msg = $module->l("you need to login with the admin account.");
} else {
    $fileType = strtolower(pathinfo($_FILES["uploader"]["name"], PATHINFO_EXTENSION));
    $fileName = Tools::encrypt(time()) . '_' . $_FILES["uploader"]["name"];
    $fileTemp = $module->pathImage . 'temps/' . $fileName;
    if (isset($_POST['width']) && intval($_POST['width']) > 0) {
        $width = intval($_POST['width']);
    } else {
        $width = null;
    }
    if (isset($_POST['height']) && intval($_POST['height']) > 0) {
        $height = intval($_POST['height']);
    } else {
        $height = null;
    }
    if (isset($_POST['maxFileSize']) && $_POST['maxFileSize']) {
        $maxFileSize = $_POST['maxFileSize'];
    }
    $maxFileSize = 1;
    // MB
    if (isset($_POST['uploadType']) && $_POST['uploadType']) {
Example #2
0
<?php

require_once dirname(__FILE__) . '../../../config/config.inc.php';
require_once dirname(__FILE__) . '../../../init.php';
require_once dirname(__FILE__) . '/simplecategory.php';
$module = new SimpleCategory();
$fileTypes = array('jpg', 'jpeg', 'png', 'gif');
$fileType = strtolower(pathinfo($_FILES["uploadimage"]["name"], PATHINFO_EXTENSION));
$fileName = time() . ".{$fileType}";
$pathFile = $module->pathImage . 'temps/' . $fileName;
$response = new stdClass();
if (!Tools::isSubmit('secure_key') || Tools::getValue('secure_key') != $module->secure_key) {
    $response->status = 0;
    $response->msg = $module->l("you need to login with the admin account.");
} else {
    $typeUpload = Tools::getValue('typeUpload', 'banner');
    $langId = Tools::getValue('langId', 1);
    if ($typeUpload == 'banner') {
        if (in_array($fileType, $fileTypes)) {
            if ($_FILES["uploadimage"]["size"] > 2000000) {
                $response->status = 0;
                $response->msg = $module->l("File size is greater than 2MB");
            } else {
                if (@move_uploaded_file($_FILES['uploadimage']['tmp_name'], $pathFile)) {
                    $response->status = 1;
                    $response->liveImage = $module->liveImage;
                    $response->fileName = $fileName;
                } else {
                    $response->msg = $module->l("File upload failed.");
                    $response->status = 0;
                }