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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
<?php
session_start();
include('DBinfo.php');
$link = mysqli_connect($host,$user,$pass,$dbname);
if (!$link) {
die('Could not connect: ' . mysqli_error($link));
}
if( isset($_POST['submit']) ){
mysqli_query($link,"SET NAMES UTF8");
$v_titre=addslashes($_POST["titre"]);
$v_keyword = addslashes($_POST["keyword"]);
$v_fait_par = addslashes($_POST["fait_par"]);
$v_desc= addslashes($_POST["description"]);
/*$v_nom_type_doc=addslashes($_POST["type"]);*/
$jour=$_POST["day"];
$mois=$_POST["month"];
$annee=$_POST["year"];
//$chemin= addslashes($_POST["fichier"]);
$query = "INSERT INTO document VALUES (\"\",\"$v_titre\",\"$v_keyword\",\"$v_fait_par\", \"$annee-$mois-$jour\", \"$v_desc\", \"1\" ,\"$chemin\")";
$res1 = mysqli_query($link,$query);
}
//header('location: Modifier.php');
?>
<!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">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Consulter</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="http://localhost/LaGED/styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<!-- Header -->
<?php include("includes/menu.php"); ?>
<!-- start page -->
<div id="page">
<!-- start content -->
<div id="content">
<h1 class="title" >Ajout d'un Document :</h1>
<form id ="monForm" method="post" enctype="multipart/form-data" action="document.php">
<fieldset>
<legend>Emplacement du Document : </legend>
<p>
<label for="fichier">Fichier (Tous formats | max. 1Mo):</label><br />
<input type="hidden" name="MAX_FILE_SIZE" value="1048576" />
<input type="file" name="fichier" id="fichier" /><br />
</p>
<p>
<input type="submit" name="upload" value="upload" />
</p>
<p>
<?echo shit;?>
</p>
</form>
<?php
if( isset($_POST['upload']) ) // si formulaire soumis
{
$content_dir = "./doc/"; // dossier où sera déplacé le fichier
$tmp_file = $_FILES['fichier']['tmp_name'];
if( !is_uploaded_file($tmp_file) )
{
exit("Le fichier est introuvable");
}
// on copie le fichier dans le dossier de destination
$name_file = $_FILES['fichier']['name'];
if( !move_uploaded_file($tmp_file, $content_dir . $name_file) )
{
exit("Impossible de copier le fichier dans $content_dir");
}
else{
$query = "INSERT INTO document VALUES ('','','','', '', '', '1' ,'$name_file'); ";
/*UPDATE document SET document.piece_jointe ='$name_file' WHERE document.doc_titre = '$v_titre*/
$res1 = mysqli_query($link,$query);
echo "Le fichier est enregistré"." -- ";
echo "$name_file ".$name_file." -- ";
echo "tmp_file ".$tmp_file;
}
}
//header('location: Modifier.php');
?>
</div>
</body>
</html> |
Partager