File Upload in PHP

<html>
<body>
<form action=”upload.php” enctype=”multipart/form-data” method=”post”>
<input type=”file” name=”myFile” id=”myFile”><br>
<input type=”submit” name=”submit” value=”Submit”>
</form>
<body>
</html>
Create another file “upload.php” that contains the code to uploading a file:
<?php
if(move_uploaded_file($_FILES[“myFile”][“tmp_name”],$_FILES[“myFile”][“name”]))
{
echo $_FILES[“file”][“name”].”Saved”;
}
else
{
echo “Unable To Save”;
}
?>
Other Parameters:-

  • $_FILES[“file”][“type”] – to get file type.
  • $_FILES[“file”][“size”] – to get file size.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.