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
|
<?php
require('connect1.php');
?>
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<?php
if( isset($_POST['upload']) ) // si formulaire soumis
{
$content_dir = '../photos/'; // dossier où sera déplacé le fichier
$tmp_file = $_FILES['name_file']['tmp_name']; }
if(!empty($descriptif) && !empty($format) && !empty($mots_cles) && !empty($lieu) && !empty($date))
{
print("<p class=titre>Descriptif : $descriptif<br>Format : $format<br>Mots-clés : $mots_cles<br>Lieu : $lieu<br>Date : $date<br></p>");
}
else if($name_file_size>200000)
{
print("<p class=titre>fichier trop lourd");
}
else
{
print("<p class=titre>remplir tous les champs</p><br>");
exit;
}
if( !is_uploaded_file($tmp_file) )
{
print("<p class=titre>le fichier est introuvable<br></p>");
}
// on vérifie maintenant l'extension
$type_file = $_FILES['name_file']['type'];
echo "uiju : $type_file<br>";
if(!strstr($type_file, 'jpg') && !strstr($type_file, 'jpeg') && !strstr($type_file, 'bmp') && !strstr($type_file, 'gif'))
//if($tmp_file_type!="image/gif" && $tmp_file_type!="image/jpg" && $tmp_file_type!="image/jpeg" && $tmp_file_type!="image/bmp")
{
exit("<p class=titre>le fichier n'est pas une image</p>");
}
// on copie le fichier dans le dossier de destination
$name_file = $_FILES['name_file']['name'];
if( !move_uploaded_file($tmp_file, $content_dir.$name_file) )
{
exit("Impossible de copier le fichier");
}
echo '<p class=titre>Le fichier a bien été uploadé</p><br>';
$sql="INSERT INTO photos VALUES ('','$name_file','$id_theme','$descriptif','$id_photographe','$format','$mots_cles','$lieu','$date')";
$req=mysql_query($sql) or die ('Erreur SQL <br>').$sql.'<br>'.mysql_error();
$sql3="SELECT nom_photographe FROM photographe WHERE id_photographe='$id_photographe'";
$req3=mysql_query($sql3) or die ('Erreur SQL3 <br>').$sql3.'<br>'.mysql_error();
$nbr3=mysql_num_rows ($req3);
for($i=0;$i<$nbr3;$i++)
{
list ($nom_photographe) = mysql_fetch_array($req3);
}
include 'miniature.php';
?>
</html> |
Partager