It would be nice if you could upload files from a form. Here a complete example how to upload a file in php.

Now start the work…..

1st you have to create a HTML form for uploading file.
The HTML form is following:

<html>
<body>
<table border=”1″ align=”center”>
<tr><td>
<form action=”upload_file.php” method=”post”
enctype=”multipart/form-data”>
<label for=”file”>Filename:</label>
<input type=”file” name=”file” id=”file” />
<input type=”submit” name=”submit” value=”Upload” />
</tr></td>
</form>
</body>
</html>

Then save it as file_upload.html.

Now create the file uploading script,

<?php
if ($_FILES["file"]["error"] > 0)
{
echo “Error: ” . $_FILES["file"]["error"] . “<br />”;
}
else
{
echo “Upload: ” . $_FILES["file"]["name"] . “<br />”;
echo “Type: ” . $_FILES["file"]["type"] . “<br />”;
echo “Size: ” . ($_FILES["file"]["size"] / 1024) . ” Kb<br />”;
echo “Stored in: ” . $_FILES["file"]["tmp_name"];
}
?>

save this as file_upload.php. Run this program.
By using the global PHP $_FILES array you can upload files from a client computer to the remote server.
This the very simple way to uploading file.