Posted by Kud on Thu 3rd May 06:31
download | new post
- <?php
- //
- // Formulaire d'envoi de fichier
- //
- include('secure.php');
- include('config.php');
- // Taille maximum du fichier envoyé
- $taille_maxi = '100000000';
- // Extentions disponibles à l'envoi
- $modification_bouton = '';
- // Création du dossier stockant les fichiers en voyant s'il n'existe pas
- {
- }
- {
- $modification_bouton = '<p>Changement :</p><p><input type="radio" checked="checked" name="modif" value="1" /><label>Important</label><input type="radio" name="modif" value="0" /><label>Minime</label></p>';
- $modification = true;
- $sql = "SELECT * FROM fichier where fic_id = '" . $_GET['file'] . "'";
- $version = $version['fic_version'];
- }
- else
- {
- $modification = false;
- $version = '1.00';
- }
- {
- if($modification == true)
- {
- $modif = $_POST['modif'];
- if($modif == '0')
- {
- $version = $version + 0.01;
- }
- if($modif == '1')
- {
- $version = $version + 1 . '.00';
- }
- }
- // Début des vérifications de sécurité
- {
- $erreur = '<p>Vous devez envoyer un fichier de type .txt, .pdf, .dwg...</p>';
- }
- if($taille>$taille_maxi)
- {
- $erreur = '<p>Le fichier est trop gros.</p>';
- }
- {
- // On formate le nom du fichier
- 'ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ',
- 'AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy');
- $fichier = $fichier . '_' . $date . '_' . $version . $extension;
- if(move_uploaded_file($_FILES['file']['tmp_name'], $dossier . $fichier)) // Si la fonction renvoie TRUE, c'est que ça a fonctionné
- {
- $message = '<p>Upload effectué avec succès !</p>';
- if($modification == true)
- {
- $sql = "UPDATE fichier SET fic_nom = '$nom_fichier', fic_url = '$fichier', fic_date = '$date', fic_version = '$version' where fic_id = '" . $_GET['file'] . "'";
- }
- else
- {
- $sql = "INSERT INTO fichier VALUES (DEFAULT, '$nom_fichier', '$fichier', '$commentaire', '$date', '$time', '$version', '" .$_SESSION['id'] . "')";
- }
- include('courriel.php');
- }
- else
- {
- $message = '<p>Echec de l\'upload !</p>';
- }
- $information = $message;
- }
- else
- {
- $information = $erreur;
- }
- }
- else
- {
- $information = '';
- }
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />
- <link rel="stylesheet" type="text/css" href="style.css" media="screen" />
- <title>Formulaire - Envoi de fichier</title>
- </head>
- <body>
- <h1>Envoi de fichiers</h1>
- <div>
- <form method="post" action="formulaire.php<?php if(isset($_GET['file'])) { echo '?file=' . $_GET['file'];} ?>" enctype="multipart/form-data">
- <p><input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $taille_maxi ?>" /></p>
- <p><label>Fichier (pdf, dwg, txt) : </label><input type="file" name="file" /></p>
- <p><label for="commentaire">Commentaire : </label><textarea name="commentaire" id="commentaire" cols="30" rows="5"></textarea></p>
- <p><input type="submit" name="envoyer" value="Envoyer" /></p>
- </form>
- </div>
- <p><a href="./liste.php">Voir la liste des fichiers</a></p>
- </body>
- </html>
Submit a correction or amendment below. (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.