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
| <?php
if ($_POST['do'] == "post") // si envoi formulaire on fait une vérification
{
//ici les test des champs
}
if ($_POST['do'] == "post" && !$err) // Si pas d erreur on envoie le formualire
{
//l'envoi, l'insert dont la parti upload photo
// Upload images
if (count($_FILES['pic']['tmp_name']))
{
$ipval = ipval();
$uploaderror = 0;
$uploadcount = 0;
foreach ($_FILES['pic']['tmp_name'] as $k=>$tmpfile)
{
if ($tmpfile)
{
$thisfile = array("name"=>$_FILES['pic']['name'][$k],
"tmp_name"=>$_FILES['pic']['tmp_name'][$k],
"size"=>$_FILES['pic']['size'][$k],
"type"=>$_FILES['pic']['type'][$k],
"error"=>$_FILES['pic']['error'][$k]);
// Check size images
if ($_FILES['pic']['size'][$k] > $pic_maxsize*1000)
{
$uploaderror++;
}
elseif (!isValidImage($thisfile))
{
$uploaderror++;
}
else
{
$newfile = SaveUploadFile($thisfile, "{$path_escape}{$datadir[adpics]}",$_POST['adtitle'], TRUE, $images_max_width, $images_max_height);
if($newfile)
{
$sql = "INSERT INTO $t_adpics
SET adid = $adid,
isevent = '$data[isevent]',
picfile = '$newfile'";
mysql_query($sql);
if (mysql_error())
{
echo "<span class=\"error\">Error uploading $_FILES[pic][name]</span><br>";
$uploaderror++;
}
else
{
$uploadcount++;
}
}
else
{
$uploaderror++;
}
}
}
elseif ($_FILES['pic']['name'][$k])
{
$uploaderror++;
}
}
if (!$in_admin && $uploadcount)
{
//echo "<p>$lang[PICTURES_UPLOADED]: $uploadcount</p>";
}
if($uploaderror)
{
if($in_admin) $err .= "$uploaderror pictures could not be uploaded";
else echo "<p class=\"err\">$lang[PICTURES_NOT_UPLOADED]: $uploaderror</p>";
}
}
}
// Ensuite mon formulaire classique
?>
<form action="post.php" method="post" name="Post" enctype="multipart/form-data">
<?php for ($i=1; $i<=$pic_count; $i++) { ?>
<input style="margin-bottom:2px;" type="file" name="pic[]" size="35"><br>
<?php } ?>
<input name="do" type="hidden" id="do" value="post">
<input type="submit" value="Valider" name="send">
</form> |
Partager