Hello,
To upload a file by using PHP, you have to follow the following steps:
1. Enable file_uploads directive
Open php.ini file and find out the file_uploads directive and make it on.
2. Create an HTML form using enctype attribute and file element for uploading the file.
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="upd" id="upd">
<input type="submit" value="Upload" name="upload">
</form>
3. Write PHP script to upload the file
if (move_uploaded_file($_FILES["upd"]["tmp_name"], "Uploads/")) {
echo "The file ". basename( $_FILES["upd"]["name"]). " is uploaded.";
} else {
echo "There is an error in uploading.";
}
Thank You!! |