|
| Total Answers and Comments: 4 |
Last Update: November 06, 2008 Asked by: rubin2008 |
|
| | |
|
Submitted by: prasantk Consider the html form:
<html>
<body>
<form action="upload_file.php" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" size="20" /><br />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>
Script for saving the uploaded file://upload_file.php
<?php
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
?>
The script above checks if the file already exists, if it does not, it copies the file to the specified folder.This example saves the file to a new folder called "upload"
Above answer was rated as good by the following members: gurukatre | Go To Top
|