This commit is contained in:
Staycie 2024-02-16 13:07:40 +08:00
commit 4a6b027f9c
3 changed files with 3 additions and 20 deletions

View File

@ -1,7 +1,8 @@
<?php
include "functions.php";
$productId = $_GET['id'];
$curl = curl_init();
$url = 'https://api.obanana.shop/api/v1/products/'.$productId;
$url = "https://".$_SESSION["data_endpoint"]."/api/v1/products/".$productId;
curl_setopt($curl,CURLOPT_URL,$url);
curl_setopt_array($curl, array(
//CURLOPT_URL => 'https://api.obanana.shop/api/v1/products/656717579624f6181c49cdda',

View File

@ -171,7 +171,7 @@ $products = productList();
if (isset($product['product_image']) && !empty($product['product_image'])) {
echo '<img src="' . $product['product_image'] . '" alt="Product Image" class="prod-img" >';
} else {
echo '<img src="assets/img/vendor/u1.jpg" class="prod-img rounded-circle" alt="Placeholder Image" >';
echo '<img src="admin/assets/img/vendor/u1.jpg" class="prod-img rounded-circle" alt="Placeholder Image" >';
}
?></td>
<td><span><?php echo $product['product_name']; ?></span></td>

View File

@ -485,24 +485,6 @@ $array = json_decode($result, true);
formData.append('category', 'product');
formData.append('image', resizedFile);
fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/upload_image', {
method: 'POST',
body: formData
})
.then(response => {
if (response.ok) {
return response.json();
} else {
console.error('File upload failed');
throw new Error('File upload failed');
}
})
.then(result => {
const filename = result.filename;
const payload = {
product_image: `https://<?php echo $_SESSION["data_endpoint"]; ?>/images/storage/product_uploads/${filename}`,
};
fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/upload_image', {
method: 'POST',
body: formData