tests
This commit is contained in:
parent
e95b57b552
commit
75900d5c12
@ -10,7 +10,8 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!-- Centered div, vertial and horizontal -->
|
<!-- Centered div, vertial and horizontal -->
|
||||||
<!-- uploads file to upload.php, shows map id after upload -->
|
<!-- uploads file to upload.php, shows map id after upload, dont go to upload.php -->
|
||||||
|
<!-- use js -->
|
||||||
<!-- Modern design, dark mode -->
|
<!-- Modern design, dark mode -->
|
||||||
<div class="flex items-center justify-center h-screen bg-gray-900">
|
<div class="flex items-center justify-center h-screen bg-gray-900">
|
||||||
<div class="w-1/2">
|
<div class="w-1/2">
|
||||||
|
27
upload.php
27
upload.php
@ -16,22 +16,13 @@ function generateMapId()
|
|||||||
return $mapId;
|
return $mapId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a JSON response
|
|
||||||
*/
|
|
||||||
function returnJson($data): void
|
|
||||||
{
|
|
||||||
echo (json_encode($data));
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the file is a zip file
|
* Checks if the file is a zip file
|
||||||
*/
|
*/
|
||||||
function isZipFile($file)
|
function isZipFile($file)
|
||||||
{
|
{
|
||||||
$fileType = strtolower(pathinfo($file, PATHINFO_EXTENSION));
|
$fileType = strtolower(pathinfo($file, PATHINFO_EXTENSION));
|
||||||
|
echo $fileType;
|
||||||
return $fileType == "zip";
|
return $fileType == "zip";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,18 +33,12 @@ $file = $map["tmp_name"];
|
|||||||
|
|
||||||
if (!isZipFile($file)) {
|
if (!isZipFile($file)) {
|
||||||
echo "The file is not a zip file";
|
echo "The file is not a zip file";
|
||||||
return;
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
$target_file = $target_dir . $mapId . ".zip";
|
$target_file = $target_dir . $mapId . ".zip";
|
||||||
if (move_uploaded_file($file, $target_file)) {
|
if (!move_uploaded_file($file, $target_file)) {
|
||||||
returnJson([
|
echo "There was an error uploading the file";
|
||||||
"status" => "success",
|
die();
|
||||||
"mapId" => $mapId
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
returnJson([
|
|
||||||
"status" => "error",
|
|
||||||
"message" => "An error occurred while uploading the file"
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
echo "The file https://wip.fascinated.cc/maps/" . $mapId . ".zip has been uploaded.";
|
||||||
|
Reference in New Issue
Block a user