Join TalkersCode Now !

Get Latest Tutorials And Links On Web Development
And Get Existing Offers Via Email

PHP File Uploading

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>

<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">



/*This is getfile.php file*/

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.


Join Us With Our 21000+ Subscribers And Get Our Latest Tutorials Update Via Email

Are You Starting A New Blog
Do You Want Best Web Hosting?

Try World's Best Web Hosting Provider BlueHost
At Just $3.95/mo

Hurry Up! Limited Time Offer

Yes, I Want To Check Out BlueHost

Check The World's Best SEO And All-In-One Marketing Toolkit
For Digital Marketing Professionals SEMRUSH