/** * Upload a file to the wiki via AJAX * * @return string */ public function ajaxRemoveTask() { // Check for request forgeries Request::checkToken(array('get', 'post')) or jexit('Invalid Token'); // Ensure we have an ID to work with $id = Request::getInt('id', 0); if (!$id) { echo json_encode(array('error' => Lang::txt('COM_STOREFRONT_ERROR_NO_ID'))); return; } $type = strtolower(Request::getWord('type', '')); $imgId = Request::getInt('currentfile', ''); // Instantiate a model, change some info and save switch ($type) { case 'product': $product = new Product($id); $product->removeImage($imgId); break; default: echo json_encode(array('error' => Lang::txt('COM_STOREFRONT_ERROR_INVALID_TYPE'))); return; break; } if (!$product->update()) { echo json_encode(array('error' => 'Error saving product')); return; } //echo result echo json_encode(array('success' => true, 'file' => '', 'id' => $id, 'size' => 0, 'width' => 0, 'height' => 0)); }