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

How To Write the FORM Tag Correctly for Uploading Files?

Advertisement
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