tp2 finit
This commit is contained in:
34
TD/TD2/d.php
34
TD/TD2/d.php
@@ -1,15 +1,37 @@
|
||||
<?php
|
||||
|
||||
$dl = false;
|
||||
require('./config.php');
|
||||
|
||||
if(isset($_POST['Envoyer'])) {
|
||||
if(!empty($_FILES['File'])) {
|
||||
$fichier = $_FILES['File'];
|
||||
|
||||
$uploadDirectory = "./d/"; // fichier d'upload
|
||||
$fileInfo = new SplFileInfo($_FILES['File']['name']); // préparation du fichier pour upload
|
||||
$nouveauFichier = $fileInfo->getFilename();
|
||||
|
||||
$pathToSave = $uploadDirectory.$nouveauFichier;
|
||||
|
||||
move_uploaded_file($_FILES['File']['tmp_name'], $pathToSave);
|
||||
|
||||
openssl_sign(file_get_contents($pathToSave), $export, file_get_contents("./b/clePrivee"));
|
||||
file_put_contents("./d/signature", $export);
|
||||
$dl = true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<html>
|
||||
<form method="POST" action="c.php">
|
||||
<label for="Code">Fichier</label> <input id="File" name="File" value=""/><br />
|
||||
<input type="submit" name="Envoyer" value="Envoyer" />
|
||||
<form method="POST" action="d.php" enctype="multipart/form-data">
|
||||
<label for="File">Fichier : </label><input type="file" id="File" name="File" value=""/><br />
|
||||
<input id="Envoyer" type="submit" name="Envoyer" value="Envoyer" />
|
||||
</form>
|
||||
<p>Texte chiffré : <?php echo $ret?></p>
|
||||
<p>Texte déchiffré : <?php echo $deret?></p>
|
||||
|
||||
<?php
|
||||
if($dl) {
|
||||
echo '<h2>Télécharger signature</h2>'
|
||||
.'<a href ="./d/signature">Télécharger</a>';
|
||||
}
|
||||
?>
|
||||
</html>
|
Reference in New Issue
Block a user