Mencarta Posted April 7, 2010 Share Posted April 7, 2010 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> Link to comment Share on other sites More sharing options...
justsomeguy Posted April 7, 2010 Share Posted April 7, 2010 That should work, if you click that button what value does it submit? You can check all of post with this:print_r($_POST); Link to comment Share on other sites More sharing options...
jeffman Posted April 7, 2010 Share Posted April 7, 2010 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? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.