-
Notifications
You must be signed in to change notification settings - Fork 1
/
upload.php
60 lines (53 loc) · 1.59 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!doctype html>
<html
<head>
<title>Uploader</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<form method="post" action="upload.php" enctype="multipart/form-data">
<ul>
<li>Fichier :<input type="file" value="Fichier" name="file" /></li>
<li>Référence :<input type="text" name="ref" /></li>
<input type="submit" value="Upload!" />
</ul>
</form>
<pre>
<?php
var_dump($_FILES);
var_dump($_POST);
$upload_dir = 'private/input/';
foreach($_FILES as $f)
{
if($f['error'])
{
echo $f['error']."\n";
continue;
}
$filename = $f['name'];
// Pas d'upload de .php
if(substr($filename, -4) == '.php') continue;
// Fichier existe
while(file_exists($upload_dir.'/'.$_POST['ref'].'/'.$filename))
{
echo 'Le fichier existe déjà, changement de nom'."\n";
$filename = 'X'.$filename;
continue;
}
@mkdir($upload_dir.'/'.$_POST['ref']);
move_uploaded_file($f['tmp_name'], $upload_dir.'/'.$_POST['ref'].'/'.$filename);
echo 'Fichier envoyé !'."\n";
}
/*
var_dump($_SERVER);
phpinfo();
*/
echo 'File uploads: '.get_cfg_var('file_uploads')."\n";
echo 'upload_max_filesize: '.get_cfg_var('upload_max_filesize')."\n";
echo 'max_input_time: '.get_cfg_var('max_input_time')."\n";
echo 'memory_limit: '.get_cfg_var('memory_limit')."\n";
echo 'max_execution_time: '.get_cfg_var('max_execution_time')."\n";
echo 'post_max_size: '.get_cfg_var('post_max_size')."\n";
?>
</pre>
</body>