$data = $backend->loadBackend(); $allowedExtensions = array("jpg", "JPG", "jpeg", "png"); $sizeLimit = 20 * 1024 * 1024; $uploader = new Media_Model($allowedExtensions, $sizeLimit); $savePath = $root . '/img-up/companies_pictures/original/'; $medium = $root . '/img-up/companies_pictures/sliders-medium/'; $pre = Tools::slugify($_POST['companyName']); $mediumWidth = 640; if ($result = $uploader->handleUpload($savePath, $pre)) { $uploader->getThumb($result['fileName'], $savePath, $medium, $mediumWidth, 'width', ''); $newData = getimagesize($medium . $result['fileName']); $wp = $newData[0]; $hp = $newData[1]; $lastId = 0; if ($newData) { $lastId = $model->addCompanySlider($_POST['companyId'], $result['fileName']); } $data = array('success' => true, 'fileName' => $result['fileName'], 'wp' => $wp, 'hp' => $hp, 'lastId' => $lastId); echo htmlspecialchars(json_encode($data), ENT_NOQUOTES); } break; // Crop // Crop case 2: $model = new Media_Model(); $data = $backend->loadBackend(); if (!empty($_POST)) { $dstWidth = 640; $dstImageHeight = 255; $source = $root . '/img-up/companies_pictures/original/' . $_POST['imgId']; $destination = $root . '/img-up/companies_pictures/sliders/' . $_POST['imgId'];