WT PPT
WT PPT
WEB TECHNOLOGIES
LIKITHA
BHOOMPALLY
237R1A0511
CSE-A
WHAT IS PHP?
• A PHP script can be used with a HTML form to allow users to upload
files to the server.
• Initially files are uploaded into a temporary directory and then relocated to a target
destination by a PHP script.
• A file upload feature enables users to send files from their local system to a
web server. The process typically involves:
File uploads must be sent via an HTML form using the POST method.
•The POST method is required because:
•It allows sending binary data (files).
•The GET method does not support file uploads as it is used for retrieving data.
upload_tmp_dir="C:\XAMPP\tmp“
• Specifies the temporary directory where uploaded files are stored before they are
moved to a permanent location.
upload_max_filesize=40M
•Defines the maximum file size allowed for an uploaded file.
•In this case, it is set to 40MB.
max_file_uploads=20
•Defines the maximum number of files that can be uploaded in a single request.
•Here, PHP allows up to 20 files to be uploaded at once.
EXAMPLE
Uploadform.html
<html><body>
<form action="uploader.php" method="post" enctype="multipart/form-
data">
Select File:
<input type="file" name="fileToUpload"/>
<input type="submit" value="Upload File" name="submit"/>
</form>
</body>
</html>
Uploader.php
<?php
$target_path = "e:/";
$target_path = $target_path.basename( $_FILES['fileToUpload']['name']);
if(move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $target_path))
{
echo "File uploaded successfully!";
} else{
echo "Sorry, file not uploaded, please try again!";
}
?>
BASIC HTML CODE