How can i make that people could only upload one image and not 2
Heres the code:
Heres the code:
//upload images
$maxfilesize = 512000; // 500kb
$allowed_types = array(
"image/gif" => "gif",
"image/pjpeg" => "jpg",
"image/jpeg" => "jpg",
"image/jpg" => "jpg",
"image/png" => "png"
);
for ($x=0; $x < 2; $x++) {
if (!($_FILES[image.$x]['name'] == "")) {
$y = $x + 1;
if (!array_key_exists($_FILES[image.$x]['type'], $allowed_types))
show_error_msg("Error","Invalid file type! Image $y",1);
if (!preg_match('/^(.+)\.(jpg|gif|png)$/si', $_FILES[image.$x]['name']))
show_error_msg("Invalid image", "This file TYPE is not image!",1);
if ($_FILES[image.$x]['size'] > $maxfilesize)
show_error_msg("Error","Invalid file size! Image $y - Must be less than 500kb",1);
$uploaddir = "".$site_config["torrent_dir"]."/images/";
$ifile = $_FILES[image.$x]['tmp_name'];
$ret = mysql_query("SHOW TABLE STATUS LIKE 'torrents'");
$row = mysql_fetch_array($ret);
$next_id = $row['Auto_increment'];
$ifilename = $next_id . $x . substr($_FILES[image.$x]['name'], strlen($_FILES[image.$x]['name'])-4, 4);
$copy = copy($ifile, $uploaddir.$ifilename);
if (!$copy)
show_error_msg("Error","Error occured uploading image! - Image $y",1);
$inames[] = $ifilename;
}
}
//end upload images