Jump to content
Sign in to follow this  
Mencarta

$_POST

Recommended Posts

I have the code

<?php	if (isset($_POST["type"])) {		if ($_FILES["file"]["error"] == UPLOAD_ERR_OK) {			if ($_POST["type"] == "pptx" && $_FILES["file"]["type"] == "application/vnd.openxmlformats-officedocument.presentationml.presentation") {				$tmp = $_FILES["file"]["tmp_name"];				$name = $_FILES["file"]["name"];				$dir = $_POST["type"]."/".$name;				move_uploaded_file($tmp,$dir);				if (file_exists($dir)) {					header("Location: uploaded.php?file=".$name);				}				else {					header("Location: error.php?file=".$name);				}			}			if ($_POST["type"] == "scrapbooks" || $_POST["type"] == "gallery" && $_FILES["file"]["type"] == "image/png" || $_FILES["file"]["type"] == "image/jpeg" || $_FILES["file"]["type"] == "image/gif") {				$tmp = $_FILES["file"]["tmp_name"];				$name = $_FILES["file"]["name"];				$dir = $_POST["type"]."/".$name;				move_uploaded_file($tmp,$dir);				if (file_exists($dir)) {					header("Location: uploaded.php?file=".$name);				}				else {					header("Location: error.php?file=".$name);				}			}			if ($_POST["type"] == "links") {				echo "OK";				$text = $_POST["link"];				$file = fopen("links.txt","w");				fwrite($file,$text);				fclose($file);			}		}	}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>	<head>		<title>Fever 1793 - Upload</title>		<link rel="stylesheet" type="text/css" href="fever.css" />		<script type="text/javascript" src="jquery.js"></script>		<script type="text/javascript">			$(function() {				$("div.file").slideUp("fast");				$("div.link").slideUp("fast");				$("input.file").click(function() {					$("div.link").slideUp("slow");					$("div.file").slideDown("slow");				});				$("input.link").click(function() {					$("div.file").slideUp("slow");					$("div.link").slideDown("slow");				});			})		</script>	</head>	<body>		<div id="header">			<h1>Fever 1793</h1>		</div>		<div id="page">			<form enctype="multipart/form-data" action="upload.php" method="post">			Upload: <input class="link" type="radio" name="type" value="links"> <b>Link</b> | <input class="file" type="radio" name="type" value="pptx"> <b>Powerpoint</b> | <input class="file" type="radio" name="type" value="scrapbooks"> <b>Scrapbook</b> | <input class="file" type="radio" name="type" value="gallery"> <b>Gallery</b>			<br />			<br />			<div class="file">				File: <input type="file" name="file">				<br />				<input type="submit" value="Upload" />			</div>			<div class="link">				Link: <input name="link" type="text" maxlength="200" />				<br />				<input type="submit" value="Upload" />			</div>			</form>		</div>	</body></html>

Share this post


Link to post
Share on other sites

That should work, if you click that button what value does it submit? You can check all of post with this:print_r($_POST);

Share this post


Link to post
Share on other sites

Remember that if no radio button in that group is checked, the key-value pair will not be posted, and your isset test will return false. I mention that because you don't clarify what you mean by "won't work."Should one of your buttons be set as the default -- that is, have a checked attribute?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...