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 114 115 116 117 118 119 120 121 122 123 124 125
|
<?php
set_time_limit(0);
?>
<!DOCTYPE html PUBLIC "//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1strict.dtd">
<html >
<head>
<title> Site de Test </title>
<meta httpequiv="ContentType" content="text/html; charset=iso88591" />
</head>
<body>
<?php
if (isset ($_GET['p']))
{
$page = $_GET['p'];
if ($page == 1)
{
if (isset ($_POST['nom']))
{
$nom = AddSlashes ($_POST['nom']);
mysql_connect("localhost", "root", "");
mysql_select_db("basetest");
mysql_query("INSERT INTO gallerie VALUES('', '" . $nom . "')");
$reponse = mysql_query("SELECT * FROM gallerie WHERE nom='$nom' ");
while ($donnees = mysql_fetch_array($reponse))
{
$id = $donnees['id'];
$nom = $donnees['nom'];
}
mkdir ("C:/Users/Nathan/Site/exemple/$id", 0700);
header("Location: ajoutphoto.php\n\n");
}
else
{
?>
<form method="post" action="ajoutphoto.php?p=1" enctype="multipart/form-data">
Nom de la gallerie: <input type="text" name="nom"/>
<input type="submit" value="Créer Gallerie"/>
</form>
<?php
}
}
elseif ($page == 2)
{
if (isset ($_GET['nbr_img']))
{
$nbr_img = $_GET['nbr_img'];
//Voici la ligne d'erreur
for ($nbr_parcourrir = 1; $nbr_parcourrir <= $nbr_img; $nbr_parcourrir)
{
if (isset($_FILES['$nbr_parcourrir']) AND $_FILES['$nbr_parcourrir']['error'] == 0)
{
if ($_FILES['$nbr_parcourrir']['size'] <= 1000000)
{
$infofichier = pathinfo($_FILES['$nbrparcourrir']['name']);
$extension_upload = $infofichier['extension'];
$extension_autorisees = array('jpg', 'jpeg', 'gif', 'png');
if (in_array($extension_upload, $extenstion_autorisees))
{
move_uploaded_file($_FILES['$nbr_parcourrir']['tmp_name'], 'test/' . basename($_FILES['$nbr_parcourrir']['name']));
echo "L\'envois a bien été effectué !";
}
}
}
}
}
else
{
?>
<form method="post" action="ajoutphoto.php?p=2" enctype="multipart/form-data">
Combien de photos avez-vous à ajouter ? : <select name="nbr_img"><?php
for ($nbr_photo = 1; $nbr_photo <= 30; $nbr_photo++)
{
echo '<option value="'.$nbr_photo.'">'.$nbr_photo.'</option>';
}?>
</select>
<input type="submit" value="OK"/>
</form>
<?php
if (isset ($_POST['nbr_img']))
{
$nbr_img = $_POST['nbr_img'];
?><form action="ajoutphoto.php?p=2&nbr_img=<?php echo ($nbr_img)?>" method="post" enctype="multipart/form-data"><?php
for ($nbr_parcourrir = 1; $nbr_parcourrir <= $nbr_img; $nbr_parcourrir++)
{?>
<input type="file" name="photo<?php $nbr_parcourrir ?>" /><br/>
<?php
}
?>
<input type="submit" value="Envoyer les photos" />
</form>
<?php
}
}
}
else
{
?>
<a href="ajoutphoto.php?p=1">Voulez vous Créer une nouvelle gallerie ?</a><br/>
<a href="ajoutphoto.php?p=2">Voulez vous ajouter des photos dans une gallerie ?</a>
<?php
}
}
else
{
?>
<a href="ajoutphoto.php?p=1">Voulez vous Créer une nouvelle gallerie ?</a><br/>
<a href="ajoutphoto.php?p=2">Voulez vous ajouter des photos dans une gallerie ?</a>
<?php
}
?>
</body>
</html> |
Partager