How to connect two files and use the radio button?

Posted by Stupefy101 on Stack Overflow See other posts from Stack Overflow or by Stupefy101
Published on 2011-01-15T14:51:12Z Indexed on 2011/01/15 14:53 UTC
Read the original article Hit count: 163

Filed under:

I have here a set of form from the index.php to upload a zip file, select an option then perform a converter process.

 <form action="" method="post" accept-charset="utf-8">
      <p class="buttons"><input type="file" value="" name="zip_file"/></p>
      </form>
      <form action="index.php" method="post" accept-charset="utf-8" name="form1">
      <h3><input type="radio" name="option" value="option1"/> Option1 </h3>
      <h3><input type="radio" name="option" value="option2"/> Option2 </h3>
      <h3><input type="radio" name="option" value="option3"/> Option3 </h3>
      <p class="buttons"><input type="submit" value="Convert"/></p>
    </form>

In the other hand, this is my code for the upload.php that will extract the Zip file.

<?php
if($_FILES["zip_file"]["name"]) {
    $filename = $_FILES["zip_file"]["name"];
    $source = $_FILES["zip_file"]["tmp_name"];
    $type = $_FILES["zip_file"]["type"];

    $name = explode(".", $filename);
    $accepted_types = array('application/zip', 'application/x-zip-compressed', 'multipart/x-zip', 'application/x-compressed');
    foreach($accepted_types as $mime_type) {
        if($mime_type == $type) {
            $okay = true;
            break;
        } 
    }

    $continue = strtolower($name[1]) == 'zip' ? true : false;
    if(!$continue) {
        $message = "The file you are trying to upload is not a .zip file. Please try again.";
    }

    $target_path = "C:xampp/htdocs/themer/".$filename;  // change this to the correct site path
    if(move_uploaded_file($source, $target_path)) {
        $zip = new ZipArchive();
        $x = $zip->open($target_path);
        if ($x === true) {
            $zip->extractTo("C:xampp/htdocs/themer/"); // change this to the correct site path
            $zip->close();

            unlink($target_path);
        }
        $message = "Your .zip file was uploaded and unpacked.";
    } else {    
        $message = "There was a problem with the upload. Please try again.";
    }
}
?>

How can i connect both files that will perform the extracting process? And how to include the codes for radio button after submission? Please Help.

© Stack Overflow or respective owner

Related posts about php