PHP uploads file - enctype="multipart/form-data" issue
- by user147685
Hi all, 
I have this upload code. there are no problem running it individually, but when i try to add into my other codes, it did not get the $_files parameter. Im guessing it was becoz of enctype="multipart/form-data" in the form tag, based on this post: 
  http://stackoverflow.com/questions/1695246/why-file-upload-didnt-work-without-enctype
the enctype is needed. SO my problem is, how can i do upload files without concern to this?
can we juz change the code structure so that it will be compatible with other codes?
  if($_POST['check']){     
    $faillampiran=$_POST['faillampiran'];
    $file=$_FILES['faillampiran']["name"];
    $fileSize = $_FILES['faillampiran']['size'];
    $fileType = $_FILES['faillampiran']['type'];
    if ($_FILES["faillampiran"]["error"] > 0 )
    {
    echo "Return Code: " . $_FILES["faillampiran"]["error"] . "<br />";
    }
    else
    {
    move_uploaded_file($_FILES["faillampiran"]["tmp_name"],"upload/" . $_FILES["faillampiran"]["name"]);
    echo '<table align = "center">';
    echo "<tr><td>";
    echo "Your file has been successfully stored.";
    echo "</td></tr>";
    echo '</table>';
    }   }
 ?>
 <form method="post" name="form1" id="form1" enctype="multipart/form-data">      
    <tr><td></td><td><input type="hidden" name="MAX_FILE_SIZE" value=""> </td> </tr>
    <tr><td> Please choose a file</td><td>:</td></tr>
    <tr>
    <input type="file" size="50" name="faillampiran" alt="faillampiran" id="faillampiran" 1value= "<?=$faillampiran;?>" />
    <tr align = "center"><td colspan = "3"><input type="submit" value="Hantar" name="check"/></td></tr>
    </tr></form> 
thank you.