Select Chapter ❯
PHP Tutorial
- PHP Introduction
- PHP Variables
- PHP Operators
- PHP Loops
- PHP Decision
- PHP Arrays
- PHP Functions
- PHP Forms
- PHP Include
- PHP File I/O
PHP Advanced
PHP Extra
PHP File Uploading
You can use PHP to upload files to server with the help of HTML Form
Example of File Upload
<!--This is file.html file-->
<!DOCTYPE html>
<html>
<body>
<form action = "upload.php" method = "post"
enctype = "multipart/form-data">
<input type="file" name="Uploadfile" id="file">
<input type="submit" value="Upload Image" name="submit">
</form>
</body>
</html>
/*This is getfile.php file*/
<?php
echo $_FILES['Uploadfile']['name'];
echo $_FILES['Uploadfile']['type'];
echo $_FILES['Uploadfile']['size'];
?>
Code Explanation
- $_FILES is used to get the files and its content.
- $_FILES['file']['tmp_name']- the uploaded file in the temporary directory on the web server.
- $_FILES['file']['name'] - the actual name of the uploaded file.
- $_FILES['file']['size'] - the size in bytes of the uploaded file.
- $_FILES['file']['type'] - the MIME type of the uploaded file.
- $_FILES['file']['error'] - the error code associated with this file upload.



