Add List Functions working and changed image-URL

This commit is contained in:
2022-11-25 01:50:02 +01:00
parent 48d3433416
commit 4f8b1d07bc
5 changed files with 116 additions and 15 deletions

View File

@@ -10,6 +10,13 @@ $ItemPrice = $_POST['ItemPrice'];
$ItemLink = $_POST['ItemLink'];
$ItemImage = $_POST['ItemImage'];
#--- check if the provided Link is a valid URL
if (filter_var($ItemLink, FILTER_VALIDATE_URL) === FALSE) {
die('Not a valid URL');
}
#---
#--- check if the provided Image-Link is a real image:
@@ -17,7 +24,7 @@ $headers = array_change_key_case(get_headers($ItemImage, 1), CASE_LOWER);
if (strpos($headers['content-type'], 'image/') !== false) {
$strippedimagepath = strtok($ItemImage, '?');
$imageLocalLink = 'data/images/' . uniqid() . '.' . pathinfo($strippedimagepath, PATHINFO_EXTENSION);
$imageLocalLink = $imagedir . '/' . uniqid() . '.' . pathinfo($strippedimagepath, PATHINFO_EXTENSION);
echo "ImageLink: " . $imageLocalLink;
file_put_contents($imageLocalLink, fopen($strippedimagepath, 'r'));
} else {