Erlaube nur png/jpg/jpeg in upload.php
This commit is contained in:
parent
28cdf2d54a
commit
19471a6f27
@ -4,11 +4,12 @@ include('config.php');
|
|||||||
|
|
||||||
if(isset($_FILES['upload'])) {
|
if(isset($_FILES['upload'])) {
|
||||||
$extension = pathinfo($_FILES['upload']['name'], PATHINFO_EXTENSION);
|
$extension = pathinfo($_FILES['upload']['name'], PATHINFO_EXTENSION);
|
||||||
|
if($extension == 'jpg' || $extension == 'jpeg' || $extension == 'png') {
|
||||||
$filename = generate_hash($hashlen) . '.' . $extension;
|
$filename = generate_hash($hashlen) . '.' . $extension;
|
||||||
move_uploaded_file($_FILES['upload']['tmp_name'], $datadir . '/' . $filename);
|
move_uploaded_file($_FILES['upload']['tmp_name'], $datadir . '/' . $filename);
|
||||||
|
|
||||||
echo json_encode(['datadir' => $datadir, 'filename' => $filename]);
|
echo json_encode(['datadir' => $datadir, 'filename' => $filename]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function generate_hash(int $length) {
|
function generate_hash(int $length) {
|
||||||
$hash = "";
|
$hash = "";
|
||||||
|
Loading…
Reference in New Issue
Block a user