picture edit

This commit is contained in:
Walter Hupfeld 2024-03-15 22:19:22 +01:00
parent d94ea09940
commit 1ac6774d66
3 changed files with 16 additions and 15 deletions

View File

@ -110,7 +110,6 @@
$boolShowmap=$numShowmap==1; $boolShowmap=$numShowmap==1;
} }
$arrTopic = array ( $arrTopic = array (
1 => "Fußverkehr", 1 => "Fußverkehr",
2 => "Radverkehr", 2 => "Radverkehr",

View File

@ -25,10 +25,8 @@ if (empty($strUsername) || empty($numLng) || empty($numLat)) {
die("not valid!"); die("not valid!");
} }
if ($boolUpload && !empty($_FILES['uploadfile']['name'])) { if ($boolUpload && !empty($_FILES['uploadfile']['name'])) {
$file=$_FILES['uploadfile']; $file=$_FILES['uploadfile'];
$uploadfile = $uploaddir . basename($file['name']);
$fileinfo = @getimagesize($file["tmp_name"]); $fileinfo = @getimagesize($file["tmp_name"]);
if (!empty($fileinfo)) { if (!empty($fileinfo)) {
//$info=read_gps_location($_FILES["uploadfile"]["tmp_name"]); //$info=read_gps_location($_FILES["uploadfile"]["tmp_name"]);

View File

@ -7,24 +7,28 @@ $strDescription = htmlentities(trim($_POST['description']));
$strDescription = addslashes($strDescription); $strDescription = addslashes($strDescription);
$numDefect = (isset($_POST['defect'])) ? $_POST['defect'] : 0; $numDefect = (isset($_POST['defect'])) ? $_POST['defect'] : 0;
$id = (int) $_POST['loc_id']; $id = (int) $_POST['loc_id'];
$filename =""; $filename = "";
$allowed_extensions = array("jpg", "jpeg", "png", "gif");
$boolUploadOk=false; $boolUploadOk=false;
if ($boolUpload && ($_FILES['uploadfile']['size']>0)) { if ($boolUpload && ($_FILES['uploadfile']['size']>0)) {
$uploadfile = $uploaddir . basename($_FILES['uploadfile']['name']); $file=$_FILES['uploadfile'];
$fileinfo = @getimagesize($_FILES["uploadfile"]["tmp_name"]); $fileinfo = @getimagesize($file["tmp_name"]);
if (!empty($fileinfo)) { if (!empty($fileinfo)) {
//$info=read_gps_location($_FILES["uploadfile"]["tmp_name"]); //$info=read_gps_location($_FILES["uploadfile"]["tmp_name"]);
$i=1; $file_extension = pathinfo($file["name"], PATHINFO_EXTENSION);
while (file_exists($uploadfile)) { if (!in_array(strtolower($file_extension), $allowed_extensions)) {
$uploadfile=$uploaddir.$i."_".basename($_FILES['uploadfile']['name']); echo "Invalid file type. Please upload only jpg, jpeg, png, or gif images.";
$i++; exit();
} }
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $uploadfile)) { $strNewfilename = uniqid("", true) . "." . $file_extension;
$filename=$_FILES['uploadfile']['name']; while (file_exists($uploaddir . $strNewfilename)) {
$filesize=$_FILES['uploadfile']['size']; $strNewfilename = uniqid("", true) . "." . $file_extension;
$filetype=$_FILES['uploadfile']['type']; }
//echo "Filetype: ".$filetype; if (move_uploaded_file($file['tmp_name'], $uploaddir.$strNewfilename)) {
$filename=$strNewfilename;//$file['name'];
$filesize=$file['size'];
$filetype=$file['type'];
$boolUploadOk = true; $boolUploadOk = true;
} else { } else {
die("Upload failed with error code " . $_FILES['file']['error']); die("Upload failed with error code " . $_FILES['file']['error']);