Add List Functions working and changed image-URL
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user