Home Answers Viewqa PHP How To Write the FORM Tag Correctly for Uploading Files?

 
 


brijesh
How To Write the FORM Tag Correctly for Uploading Files?
2 Answer(s)      2 years and 6 months ago
Posted in : PHP

How To Write the FORM Tag Correctly for Uploading Files?

View Answers

November 12, 2010 at 4:04 PM


Write like this in ur programe


November 13, 2010 at 4:28 PM


Hi,

The "html" form code for uploading file is:

<html>
<body>

<form action="uploadfiles.php" method="post"
enctype="multipart/form-data">
<label>Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>

</body>
</html>

The uploadfiles.php code is:

<?php
if ($_FILES["file"]["error"] > 0)
  {
  echo "Error: " . $_FILES["file"]["error"] . "<br />";
  }
else
  {
  echo "Upload: " . $_FILES["file"]["name"] . "<br />";
  echo "Type: " . $_FILES["file"]["type"] . "<br />";
  echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
  echo "" . $_FILES["file"]["tmp_name"];
  }
?>

Thanks









Related Pages:

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.