当客户单击选项 2 IMG 时,我需要这个简单的代码 它向他展示了两张输入上传图片,当他选择数字 1 IMG 选项时,只会出现一张输入上传图片。并隐藏 2 个输入上传选项
请帮忙,我怎样才能按照我遵循并搜索的这种格式执行此代码,但我无法做到,而且我没有找到足够的解释
<div class="upload-btn-wrapper">
<label for="file" class="btns" id="file-label">
Upload Image
</label>
<input type="file" class="file" action="" name="file" id="file" accept="image/*">
</div>
<select id="X" name="X">
<option value="1">1 IMG</option>
<option value="2">2 IMG</option>
</select>
他是使用它的php代码
if (isset($_POST["submit"])) {
$allowed_image_extension = array(
"png",
"jpg",
"jpeg",
"gif"
);
$uploadOk = 1;
// Get image file extension
$file_extension = strtolower(pathinfo($_FILES["file"]["name"], PATHINFO_EXTENSION));
// Validate file input to check if is not empty
if (! file_exists($_FILES["file"]["tmp_name"])) {
$uploadOk = 0;
$response = array(
"type" => "error",
"message" => "Choose image file to upload."
);
} // Validate file input to check if is with valid extension
else if (! in_array($file_extension, $allowed_image_extension)) {
$uploadOk = 0;
$response = array(
"type" => "error",
"message" => "Upload Valid Images. Only PNG, JPEG, JPG, GIF, Are Allowed."
);
} // Validate image file size
else if (($_FILES["file"]["size"] > 5000000)) {
$uploadOk = 0;
$response = array(
"type" => "error",
"message" => "Image Size Exceeds 5MB."
);
}
// Get Ip Cilent For Upload
$upload_folder = "Uploads/";
// boundary
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// headers for attachment
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
// multipart boundary
$message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
$message .= "--{$mime_boundary}\n";
$content = '';
$tmp_path = $_FILES["file"]["tmp_name"];
if($tmp_path) {
$filename = $_FILES["file"]["name"];
$file = $upload_folder . $filename;
if(!copy($tmp_path, $file))
{
$errors = '\n error while copying the uploaded file';
}
$file_size = filesize($file);
$handle = fopen($file, "rb");
$content = fread($handle, $file_size);
fclose($handle);
$content = chunk_split(base64_encode($content));
}
// if attachment
if ($content) {
$message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"{$filename}\"\n" .
"Content-Disposition: attachment;\n" . " filename=\"{$filename}\"\n" .
"Content-Transfer-Encoding: base64\n\n" . $content . "\n\n";
$message .= "--{$mime_boundary}\n";
mail($send, $subject, $message, $headers);
}
//Vaildation Error Mag Before Redirection
if ($uploadOk == 1) {
header("Location:NEXT.PHP");
}
}