File Upload in PHP

Google Advertisements

String Function in PHP Next Tutorial

File Upload in PHP

PHP allows you to upload single and multiple files through few lines of code only. PHP file upload features allows you to upload binary and text files both. Moreover, you can have the full control over the file to be uploaded through PHP authentication and file operation functions.

file upload in php

First, ensure that PHP is configured to allow file uploads. In your "php.ini" file, search for the file_uploads directive, and set it to On.


file_uploads = On


The PHP global $_FILES contains all the information of file. By the help of $_FILES global, we can get file name, file type, file size, temp file name and errors associated with file.

  • $_FILES['filename']['name'] It returns file name.
  • $_FILES['filename']['type'] It returns MIME type of the file.
  • $_FILES['filename']['size'] It returns size of the file (in bytes).
  • $_FILES['filename']['tmp_name'] It returns temporary file name of the file which was stored on the server.
  • $_FILES['filename']['error'] It returns error code associated with this file.


<!DOCTYPE html>

<form action="uploader.php" method="post" enctype="multipart/form-data">
    Select File:  
    <input type="file" name="fileToUpload"/>
    <input type="submit" value="Upload Image" name="submit"/>




$target_path = "c:/";  
$target_path = $target_path.basename( $_FILES['fileToUpload']['name']);   
if(move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $target_path)) 
    echo "File uploaded successfully!";  
  echo "Sorry, file not uploaded, please try again!";  


String Function in PHP Next Tutorial

Google Advertisements

We have more than 5 Groups which have 500000+ Members and some Pages have more than 100000+ members. For Advertisement contact on or 9999595223

Buy This Ad Space @$50 per Month, Ad Size 600X200 Contact on: or 8076671483

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Classpath variable is set for providing a path for predefined Java classes which is used in our application. All classes are available in lib/rt.jar so we set classpath upto lib/rt.jar. Difference between path and classpath in Java

Cloud computing is the on demand availability of computer system resources, especially data storage and computing power, without direct active management by the user. Cloud Computing Tutorial

College Projects Related to Java, AWT, C Projects for College, C++ Projects for College, Android Projects. Download Java C C++ Projects

Download Projects

Adsense Advertisements

Buy This ads Space 8076671483

Buy This Ad Space @$120 per Month, Ad Size 300X600 Contact on: or 8076671483 Try this Keyword C++ Programs