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
| <!DOCTYPE html>
<html>
<head>
<title>Les Glaces du Lac - Rentabilité</title>
<meta charset="UTF-8" />
</head>
<body>
<form action="index.php" method="post" enctype="multipart/form-data">
<input type="text" name="nom" />
<input type="file" name="file" />
<input type="submit" />
</form>
<?php
if (isset($_FILES['file']) AND $_FILES['file']['error'] == 0) {
if ($_FILES['file']['size'] <= 1000000) {
$infosfichier = pathinfo($_FILES['file']['name']);
$extension_upload = $infosfichier['extension'];
$extensions_autorisees = array('ods', 'png');
if (in_array($extension_upload, $extensions_autorisees)) {
move_uploaded_file($_FILES['file']['tmp_name'], 'uploads/' . basename($_FILES['file']['name']));
echo "L'envoi a bien été effectué !";
$adress = "./uploads/" . $_FILES["file"]["name"];
$element = pathinfo($adress);
$nom = $element['filename'];
$zip = new ZipArchive();
if ($zip -> open($nom . '.zip') == TRUE)
if ($zip -> open($nom . '.zip', ZipArchive::CREATE) == TRUE) {
echo '"Zip.zip" ouvert';
$zip -> close();
} else {
echo 'Impossible d'ouvrir "Zip.zip"';
}
}
}
}
?>
</body>
</html> |