$fileBody = preg_replace('#^data.*?base64,#', '', $fileBody); $fileBody = base64_decode($fileBody); // сохраем файл $nameFile = $fileName . '.' . $fileType; file_put_contents($nameFile, $fileBody); $photo = str_replace('../', '', $nameFile); $arrTmpPhoto[] = $photo; } $array_photoTMP = array(); foreach ($arrTmpPhoto as $key111 => $value111) { $array_photoTMP[] = array("photo" => $arrTmpPhoto[$key111], "color" => $_POST["colors"][$key111]); } if ($_POST["go"] != "save") { DB::deletePhoto($_POST["go"]); } Product::insertPhoto($array_photoTMP, $lastId); header("Location: production.php?id=" . $_POST["section"]); } require_once "classes/Catalog.php"; $section = new Catalog(); require_once "classes/Product.php"; $objEdit = new Product(); $related = $objEdit->selectAll(); $colors = DB::select("colors"); if (isset($_GET["edit"])) { $record = DB::selectID("price", $_GET['edit']); // $nowSection = DB::selectParam("catalog","id",$record[0]['section'],false,"limit 1"); $record = $objEdit->selectId($_GET['edit']); $nowSection = $objEdit->selectSectionId($_GET['edit']); } require_once 'view/tpl_top.php';
preg_match('#data:image\\/(png|jpg|jpeg|gif);#', $fileBody, $fileTypeMatch); $fileType = $fileTypeMatch[1]; // декодируем содержимое файла $fileBody = preg_replace('#^data.*?base64,#', '', $fileBody); $fileBody = base64_decode($fileBody); // сохраем файл $nameFile = $fileName . '.' . $fileType; file_put_contents($nameFile, $fileBody); $photo = str_replace('../', '', $nameFile); $arrTmpPhoto[] = $photo; } $arrPhoto = array_combine($_POST["colors"], $arrTmpPhoto); if ($_POST["go"] != "save") { DB::deletePhoto($_POST["go"]); } Product::insertPhoto($arrPhoto, $lastId); header("Location: production.php?id=" . $_POST["section"]); } require_once "classes/Catalog.php"; $section = new Catalog(); require_once "classes/Product.php"; $objEdit = new Product(); $related = $objEdit->selectAll(); $colors = DB::select("colors"); if (isset($_GET["edit"])) { $record = DB::selectID("price", $_GET['edit']); $nowSection = DB::selectParam("catalog", "id", $record[0]['section'], false, "limit 1"); $record = $objEdit->selectId($_GET['edit']); $nowSection = $objEdit->selectSectionId($_GET['edit']); } require_once 'view/tpl_top.php';