envoiFichiers.php 1.9 KB
<?php
session_start();
?>
<!DOCTYPE html>

<html>
	<head>
		<?php include("head.php"); ?>
	</head>

	<!-- Contenu du site -->
	<body>
		<?php 
		include("header.php");
		$upload1 = upload('fichier',FALSE, array('c', 'txt') );
		?>
		<div class="row">
			<div class="col-4 col-md-4 offset-md-4 offset-4">
				<br/>
				<h1 style="margin-bottom:50px; margin-top:50px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fa fa-cloud"></i> Envoi du fichier en ligne</h1>
				<?php if($upload1){
					inc_num();
					?>
					<div class="alert alert-success" role="alert">
					  Upload du fichier réussi !
					</div>
					<?php
				}
				else {?>
					<div class="alert alert-danger" role="alert">
						Erreur lors du transfert du fichier !
					</div><?php 
				}
				?>
				<h1 style="margin-bottom:50px; margin-top:50px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fa fa-info-circle"></i> Informations complémentaires</h1>
				<table class="table table-striped table-bordered">
					<tbody>
						<tr>
							<td>Nom du fichier</td>
							<td><?php echo $_FILES['fichier']['name'];?></td>
						</tr>
						<tr>
							<td>Type</td>
							<td><?php echo $_FILES['fichier']['type'];?></td>
						</tr>
						<tr>
							<td>Localisation</td>
							<td><?php echo $_FILES['fichier']['tmp_name'];?></td>
						</tr>
						<tr>
							<td>Erreur</td>
							<td><?php echo $_FILES['fichier']['error'];?></td>
						</tr>
						<tr>
							<td>Taille</td>
							<td><?php echo $_FILES['fichier']['size'];?></td>

						</tr>
					</tbody>
				</table>

			</div>
		</div>
	</body>
</html>

<?php 
if ( isset($_POST['sensor']) ) {
	$xml = "<?xml version='1.0' encoding='ISO-8859-1'?>\r\n"
	. '<sensor>' . htmlspecialchars($_POST['sensor']) . '</sensor>' ;
        file_put_contents('upload/sensor.xml', $xml) ;
}
if ( isset($_POST['sensor']) ) {
	$txt = get_num();
	file_put_contents('upload/demande.txt', $txt);
}
?>