In this topic we discuss on uploading a file on server,to allow users to upload files from server using php the look at following html form for uploading files.
<html>
<head>
<title>Upload File</title>
</head>
<body>
<form method="post" enctype=" multipart/form-data">
<input type="file" name="file">
<br>
<input type="submit" name="upload" value="Upload">
</form>
</body>
</html>
The enctype atribute of the <form> tag specifies which conten type to use when submitting the form."multipart/form-data" is used when a form requires bunary data,like the contents of a file,to be uploaded.
The type="file" attribute of the <input> tag specifies that the input should be processed as a file.for example when viewed in a browser,there will be a browse-button next to the input fied.
The using the global PHP $_FILES array you can upload files from a client computer to the remote server.the first parameter is the form's input name and the second index can be either "name","type","size""tmp_name" or "error" .the following example.
<?php
$FILES["file"]["name"] //the name of the uploaded file
$_FILES["file"]["type"] //the type of the uploaded file
$_FILES["file"]["size"] //the size in bytes of the uploaded file
$_FILES["file"]["tmp_name"] //the name of the temporary copy of the file stored on the server
$_FILES["file"]["error"] //the error code resulting from the file upload
?>