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
|
<?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"];
$query = "INSERT INTO document VALUES ('','$v_titre','$v_keyword','$v_fait_par', '$annee-$mois-$jour', '$v_desc', '1' ,'')";
$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">
// mon code html qui contient un input de name 'upload'
<?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 = "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');
?>
</html> |
Partager