hi all
i will upload a file with form .
I have a problem to do it.
when I submitted the form if my form content enctype="multipart/form-data" the all of the fild's form not pass by post method.
I work on Unix and apachi
my script is:
----------
<?php
if(isset($HTTP_FILES_VARS['f1']))
echo "ok";
else
echo "no";
?>
<form action="test_form.php" enctype="multipart/form-data" method="post">
<input type="file" name="f1">
<input type="submit" name="sub">
</form>
BUT if my form haven't enctype="multipart/form-data" then i have all variable.
i don't know it.
please help me
multipart/form-data
Moderator: General Moderators
-
sleepingdanny
- Forum Newbie
- Posts: 12
- Joined: Thu Mar 20, 2003 4:27 am
- Location: Israel
You don't need to use: $HTTP_FILES_VARS['f1']
You can just write: $f1
You can just write: $f1
Code: Select all
<?php
if(isset($f1)){
echo "ok";
}
else{
echo "no";
}
?>Code: Select all
<form action="" enctype="multipart/form-data" method="post">
<input type="file" name="f1">
<input type="submit" name="sub">
</form>$f1 will only be available if register_globals is enabled, which is deprecated and might not be supported in future versions of php.
as a small example to see what is stored where when using multipart/form-data try
as a small example to see what is stored where when using multipart/form-data try
Code: Select all
<html>
<body>
<?php
if (count($_FILES) > 0)
{
?>
<fieldset><legend>contents of array $_FILES</legend>
<pre><?php print_r($_FILES); ?></pre>
</fieldset>
<?php
}
if (count($_POST) > 0)
{
?>
<fieldset><legend>contents of array $_POST</legend>
<pre><?php print_r($_POST); ?></pre>
</fieldset>
<?php
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data" method="post">
<p>
<input type="file" name="f1" />
<input type="checkbox" name="c1" id="c1" /><label for="c1">are you sure?</label>
<br />
<input type="text" name="comment" id="comment"><label for="comment">your comment</label>
<br />
<input type="submit" />
</p>
</form>
</body>
</html>