Home  • Programming • PHP

Simple Photo Upload in php

1. First create a folder name uploads to your web server. 2. Then create a PHP file name upload.php to the same location as your uploads folder. 3. Now write the following code to the upload.php file:
<?php
	
	if(isset($_POST["btnSubmit"])){
		$photo=$_FILES["file"]["name"];	
                copy($_FILES["file"]["tmp_name"],"uploads/".$photo);
		echo "Successfully Uploaded";
	}
?>

<form action="#" method="post" enctype="multipart/form-data">
    Album Image : <input type="file" name="file" />
    <input type="submit" name="btnSubmit" value="Submit" />
</form>
4. Run your script with a browser and submit 5. Now check your photo to uploads folder.

Comments 1


It would be helpful if you show how to restrict and upload multiple files too its an advice.....
About Author
Md. Saydul Alam
Copyright © 2024. Powered by Intellect Software Ltd