-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.php
33 lines (28 loc) · 929 Bytes
/
upload.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
require('conexao.php');
// var_dump($_FILES['file']);
if (isset($_FILES['file']) && $_FILES['file']['size'] > 0) {
$file = $_FILES['file'];
$pasta = 'arquivos/';
$nome_file = uniqid();
$extensao = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION));
if ($extensao != 'png' && $extensao != 'jpeg') {
header('Location: ./');
exit;
}
$point_end = move_uploaded_file($file['tmp_name'], $pasta . $nome_file . '.' . $extensao);
$point_url = $pasta . $nome_file . '.' . $extensao;
if ($point_end) {
$conexao->query("INSERT INTO arquivos (path , data_upload, usuario) VALUES ('$point_url','" . date('d/m/y') . "','Geremias')");
header('Location: ./index.php?upload=ok');
exit;
} else {
header('Location: ./');
exit;
}
} else {
header('Location: ./');
exit;
}
// 1024 bytes = 1 kb
// 1024 kb = 1 mb