file upload

This commit is contained in:
Walter Hupfeld 2024-03-12 20:34:11 +01:00
parent d6312dc965
commit 882fb90145

View File

@ -1,5 +1,5 @@
<?php <?php
/******************************* /* ******************************
* Ideenmelder * Ideenmelder
* Autor: Walter Hupfeld, Hamm * Autor: Walter Hupfeld, Hamm
* E-Mail: info@hupfeld-software.de * E-Mail: info@hupfeld-software.de
@ -33,10 +33,9 @@
$result->bindParam(":district",$strDistrict); $result->bindParam(":district",$strDistrict);
$result->execute(); $result->execute();
/* Für die Auswertung nur bestimmte Kategorien anzeigen /* Für die Auswertung nur bestimmte Kategorien anzeigen
$numDefect="(6,8,21)"; $numDefect="(6,8,21)";
$strSQL="SELECT loc.*,f.filename FROM location loc LEFT JOIN files f ON loc.id=f.loc_id WHERE defect in ".$numDefect; $strSQL="SELECT loc.*,f.filename FROM location loc LEFT JOIN files f ON loc.id=f.loc_id WHERE defect in ".$numDefect;
*/ */
$arrMarker = array(); $arrMarker = array();
$arrDescription = array(); $arrDescription = array();
$id=0; $id=0;
@ -68,8 +67,6 @@
<meta name="author" content="Walter Hupfeld, info@hupfeld-software.de"> <meta name="author" content="Walter Hupfeld, info@hupfeld-software.de">
<meta name="description" content="Georeferenzieter Ideenmelder"> <meta name="description" content="Georeferenzieter Ideenmelder">
<script src="js/jquery.min.js"></script> <script src="js/jquery.min.js"></script>
<script src="js/leaflet.js"></script> <script src="js/leaflet.js"></script>
<script src="js/leaflet.ajax.js"></script> <script src="js/leaflet.ajax.js"></script>
@ -88,7 +85,6 @@
</head> </head>
<body> <body>
<!-- Navbar --> <!-- Navbar -->
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top"> <nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a class="navbar-brand" href="#"><?= $strTitle ?> <?=$strDistrictTitle?></a> <a class="navbar-brand" href="#"><?= $strTitle ?> <?=$strDistrictTitle?></a>
@ -116,8 +112,6 @@
</form> </form>
<?php endif; ?> <?php endif; ?>
</ul> </ul>
<div> <div>
<ul class="navbar-nav mr-auto right"> <ul class="navbar-nav mr-auto right">
<li class="nav-item"> <li class="nav-item">
@ -158,7 +152,6 @@
<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-1"> <main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-1">
<div id="mapid"></div> <div id="mapid"></div>
</main> </main>
</div> </div>
<!-- row --> <!-- row -->
</div> </div>
@ -458,6 +451,7 @@
var _URL = window.URL || window.webkitURL; var _URL = window.URL || window.webkitURL;
if ((file = this.files[0])) { if ((file = this.files[0])) {
var file = this.files[0]; var file = this.files[0];
console.log(file["size"]);
var fileType = file["type"]; var fileType = file["type"];
var validImageTypes = ["image/gif", "image/jpeg", "image/png"]; var validImageTypes = ["image/gif", "image/jpeg", "image/png"];
if ($.inArray(fileType, validImageTypes) < 0) { if ($.inArray(fileType, validImageTypes) < 0) {
@ -465,18 +459,18 @@
alert("Keine Bilddatei, nur gif,jpeg,png erlaubt.") alert("Keine Bilddatei, nur gif,jpeg,png erlaubt.")
$("#photo").val(""); $("#photo").val("");
} }
//if (file["size"]>1000000) { alert("Bilder sollten maximal 1 MB groß sein");}
if (image_ok) { if (image_ok) {
img = new Image(); img = new Image();
var objectUrl = _URL.createObjectURL(file); var objectUrl = _URL.createObjectURL(file);
img.onload = function () { img.onload = function () {
image_ok = (this.width<2000 && this.height<2000 && this.width>100 && this.height>100); image_ok = (this.width<4000 && this.height<4000 && this.width>100 && this.height>100);
//console.log("Breite:" + this.width + " Höhe: " + this.height);
console.log("Breite:" + this.width + " Höhe: " + this.height); /*
console.log(this);
if (!image_ok) { if (!image_ok) {
alert("Bilder dürfen maximal 2000 x 2000 Pixel groß sein.\n" alert("Bilder dürfen maximal 2000 x 2000 Pixel groß sein.\n"
+"Breite:" + this.width + " Höhe: " + this.height) +"Breite:" + this.width + " Höhe: " + this.height)
} }*/
}; };
img.src = objectUrl; img.src = objectUrl;
} }