<?php // Security if ($SMCallback !== true) { echo "Unauthorized!"; // Not executed in the context of Sitemagic exit; } if (SMAuthentication::Authorized() === false) { throw new exception("Unauthorized!"); } // Parameters $imagesFolder = SMEnvironment::GetDataDirectory() . "/SMShop"; $command = count($_FILES) > 0 ? "Upload" : "Remove"; // Upload file if ($command === "Upload") { if (isset($_FILES["SelectedFile"]) === false || $_FILES["SelectedFile"]["error"] !== 0 || $_FILES["SelectedFile"]["name"] === "") { header("HTTP/1.1 500 Internal Server Error"); echo "Error"; exit; } // File information $dir = $imagesFolder; $filename = $_FILES["SelectedFile"]["name"]; // Ensure target folder if (SMFileSystem::FolderExists($dir) === false) { $res = SMFileSystem::CreateFolder($dir); if ($res === false) { header("HTTP/1.1 500 Internal Server Error"); echo "Error - unable to create '" . $dir . "'"; exit;