Functionnal .wav upload
This commit is contained in:
parent
2e065a5bad
commit
afbc3ed382
BIN
public/storage/records/PaRecAR628069_20200526_040726.wav
Normal file
BIN
public/storage/records/PaRecAR628069_20200526_040726.wav
Normal file
Binary file not shown.
@ -235,4 +235,8 @@ div.coordinates {
|
||||
|
||||
div.coordinates input[type="text"] {
|
||||
width: 25em;
|
||||
}
|
||||
|
||||
.sci-name {
|
||||
font-style: italic;
|
||||
}
|
0
public/test-file-upload.php
Normal file
0
public/test-file-upload.php
Normal file
13
public/test/file.php
Normal file
13
public/test/file.php
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<form action="upload.php" method="post" enctype="multipart/form-data">
|
||||
Select image to upload:
|
||||
<input type="file" name="fileToUpload" id="fileToUpload">
|
||||
<input type="submit" value="Upload Image" name="submit">
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
33
public/test/upload.php
Normal file
33
public/test/upload.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
$root = realpath($_SERVER["DOCUMENT_ROOT"]);
|
||||
$target_dir = $root."/storage/records";
|
||||
echo $target_dir;
|
||||
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
|
||||
$uploadOk = 1;
|
||||
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
|
||||
$MAXIMUM_FILESIZE = 10000 * 1024 * 1024;
|
||||
// Check if image file is a actual image or fake image
|
||||
if(isset($_POST["submit"])) {
|
||||
if (is_uploaded_file($_FILES['fileToUpload']['tmp_name'])) {
|
||||
$safe_filename = preg_replace(
|
||||
array("/\s+/", "/[^-\.\w]+/"),
|
||||
array("_", ""),
|
||||
trim($_FILES['fileToUpload']['name']));
|
||||
if ($_FILES['fileToUpload']['size'] <= $MAXIMUM_FILESIZE)
|
||||
{
|
||||
$isMove = move_uploaded_file (
|
||||
_FILES['fileToUpload']['tmp_name'],
|
||||
$dir_base.$safe_filename);
|
||||
|
||||
if ($isMove) {
|
||||
echo "File moved";
|
||||
} else {
|
||||
echo "File not moved";
|
||||
}
|
||||
} else {
|
||||
echo "Maximum file size exceeded";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -3,6 +3,9 @@ ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
session_start();
|
||||
if (! isset($_SESSION['error_msg'])) {
|
||||
$_SESSION['error_msg'] = "";
|
||||
}
|
||||
|
||||
$root = realpath($_SERVER["DOCUMENT_ROOT"]);
|
||||
?>
|
||||
|
File diff suppressed because one or more lines are too long
18
public/upload/scripts/checkmap.js
Normal file
18
public/upload/scripts/checkmap.js
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
|
||||
if (typeof coordinates !== 'undefined') {
|
||||
lat = coordinates.split(",")[0];
|
||||
lng = coordinates.split(",")[1];
|
||||
let latlng = L.LatLng(lat, lng);
|
||||
let marker = L.marker(latlng, draggable=false).addTo(mycheckmap);
|
||||
let mycheckmap = L.map('checkmap').setLatLng(latlng);
|
||||
|
||||
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
|
||||
attribution: 'Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
|
||||
maxZoom: 18,
|
||||
id: 'mapbox/streets-v11',
|
||||
tileSize: 512,
|
||||
zoomOffset: -1,
|
||||
accessToken: 'pk.eyJ1IjoidW5jbGVzYW11bHVzIiwiYSI6ImNrbXQwNDl5MTBtc2gybm82b3c0M3VoNncifQ.qUqAuCuMDF38NcyrAC1RJQ'
|
||||
}).addTo(mycheckmap);
|
||||
}
|
@ -26,3 +26,4 @@ function onMapClick(e) {
|
||||
}
|
||||
|
||||
mymap.on('click', onMapClick);
|
||||
|
||||
|
@ -4,12 +4,13 @@ ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
$root = realpath($_SERVER["DOCUMENT_ROOT"]);
|
||||
$target_dir = root."/storage/records";
|
||||
$target_dir = $root."/storage/records/";
|
||||
$fileName = $_FILES['file']['name'];
|
||||
$target_file = $target_dir.basename($_FILES['file']['name']);
|
||||
$uploadOk = 1;
|
||||
$fileSize = $_FILES['file']['size'];
|
||||
$fileExtension = strtolower(end(explode('.', $fileName)));
|
||||
$temp = explode('.', $fileName);
|
||||
$fileExtension = strtolower(end($temp));
|
||||
$_SESSION['error_msg'] = "Form not submitted.\n";
|
||||
|
||||
if (isset($_POST['submit']))
|
||||
@ -20,7 +21,7 @@ if (isset($_POST['submit']))
|
||||
{
|
||||
$_SESSION['error_msg'] .= "This file extension is not allowed; please upload a WAV file.\n";
|
||||
}
|
||||
if ($fileSize > 10000000)
|
||||
if ($fileSize > 10*1024*1024)
|
||||
{
|
||||
$_SESSION['error_msg'] .= "The file size must be below 10MB. \n";
|
||||
}
|
||||
@ -37,6 +38,7 @@ if (isset($_POST['submit']))
|
||||
if (isset($_POST['species']))
|
||||
{
|
||||
$_SESSION['observation']['species'] = $_POST['species'];
|
||||
setcookie('species', $_SESSION['observation']['species'], time() + 86400 * 365.2, "/");
|
||||
} else
|
||||
{
|
||||
$_SESSION['error_msg'].= "Error, incorrect species name.\n";
|
||||
@ -44,6 +46,7 @@ if (isset($_POST['submit']))
|
||||
if (isset($_POST['subspecies']))
|
||||
{
|
||||
$_SESSION['observation']['subspecies'] = $_POST['subspecies'];
|
||||
setcookie('subspecies', $_SESSION['observation']['subspecies'], time() + 86400 * 365.2, "/");
|
||||
} else
|
||||
{
|
||||
$_SESSION['observation']['subspecies'] = "";
|
||||
@ -51,6 +54,7 @@ if (isset($_POST['submit']))
|
||||
if (isset($_POST['recording-license']))
|
||||
{
|
||||
$_SESSION['observation']['license'] = $_POST['recording-license'];
|
||||
setcookie('license', $_SESSION['observation']['license'], time() + 86400 * 365.2, "/");
|
||||
} else
|
||||
{
|
||||
$_SESSION['error_msg'] .= "Incorrect license\n";
|
||||
@ -58,6 +62,7 @@ if (isset($_POST['submit']))
|
||||
if (isset($_POST['name']))
|
||||
{
|
||||
$_SESSION['observation']['name'] = $_POST['name'];
|
||||
setcookie('name', $_SESSION['observation']['name'], time() + 86400 * 365.2, "/");
|
||||
} else {
|
||||
$_SESSION['error_msg'] .= "Incorrect Recordist Name.\n";
|
||||
}
|
||||
|
@ -47,7 +47,7 @@
|
||||
<tr>
|
||||
<tr>
|
||||
<td>Quality</td>
|
||||
<td><?$_SESSION['observation']['quality']?></td>
|
||||
<td><?=$_SESSION['observation']['quality']?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Remarks</td>
|
||||
@ -56,3 +56,20 @@
|
||||
</tbody></table>
|
||||
<h2>Location</h2>
|
||||
|
||||
<div id="checkmap" style="height: 250px; border: 1px solid #AAA;"></div>
|
||||
|
||||
<script type='text/javascript' src='/scripts/jquery/script.js'></script>
|
||||
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
|
||||
integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
|
||||
crossorigin=""></script>
|
||||
<script src="scripts/checkmap.js">
|
||||
let coordinates = <?= $_SESSION['observation']['latlng']?>;
|
||||
</script>
|
||||
|
||||
|
||||
<form action="submitobservation" method="post">
|
||||
<input type="checkbox" id="allok" name="allok">
|
||||
<label for="allok">All informations are ok.</label><br>
|
||||
<input type="submit" name="submit" value="submit">
|
||||
</form>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user