我一直在努力使用这段代码。我想同时上传几张图片,但它并没有让我到处都是。我希望允许我的用户为他们的广告列表上传三张图片。感谢您的帮助。
<?php
if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0 )
$title = clean($_POST['title']);
$description = clean($_POST['description']);
$category = clean($_POST['category']);
$price = clean($_POST['price']);
$name = clean($_POST['name']);
$number = clean($_POST['number']);
$email = clean($_POST['email']);
$subcategory = clean($_POST['subcategory']);
$state = clean($_POST['state']);
$city = clean($_POST['city']);
$imagename = basename($_FILES['userfile']['name']);
// PICTURE UPLOAD SYSTEM
$imagename = basename($_FILES['userfile']['name']);
if(empty($imagename)) {
$error = 1;
echo"<h2 class='error'>Image not found</h2>".$back; }
if($error != 1 && $noimg != 1)
{
$filename = stripslashes($_FILES['userfile']['name']);
$extension = substr(strrchr($filename, '.'), 1);
$extension = strtolower($extension);
//if it is not a known extension, we will suppose it is an error and will not
// upload the file,
//otherwise we will do more tests
}
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") &&
($extension != "gif"))
{
//print error message
echo "<h2 class='error'> Images Must Be Jpg, Gif, or Png Format!
</h2>".$back.'';
$errors=1;
}
else
{
$time = time();
$newimage = "photos/" . $time . $imagename;
//echo $newimage;
$result = @move_uploaded_file($_FILES['userfile']['tmp_name'], $newimage);
if(empty($result)) {
$error = 1;
echo "<h2 class='error'>".$lang['MOVING_UPLOAD_FILE']."</h2><br/>".$back."";
}
$date = date("Y-m-d G:i:s") ;
$query = "INSERT INTO classifieds (id, title, description, state_id, city_id,
subcat_id, cat, price, name, number, email, picture, date) VALUES ('', '$title',
'$description', '$state', '$city', '$subcategory', '$category', '$price', '$name',
'$number', '$email', '$newimage', '$date')";
mysql_query($query) or die(mysql_error());
?>
<form action="send.php" method="post" name="form" enctype="multipart/form-data">
再次感谢