This is small example for beginners, how to upload files with PHP, this method is very simple and it can be used at every server which supports PHP. We will use 2 files upload.html, and upload.php, by default files uploaded in /upload directory, make sure that upload directory is writable.
upload.html
<html> <body> <form action='upload.php' method='post' enctype='multipart/form-data' /> <input type='file' name='filename' /><br /> <input type='submit' value='submit' /><br /> </form> </body> </html>
upload.php
<? //Test file size which must not be more then 3MB if($_FILES['filename']['size'] > 1024*3*1024) { echo "File is more then 3MB!"; exit; } //Test File Input if($_FILES['filename']['name'] == ''){ echo "You must browse the file!"; }else{ //If file pointed start Upload In /upload Path if(move_uploaded_file($_FILES['filename']['tmp_name'], "upload/" .$_FILES['filename']['name'])){ echo "File Uploaded!"; }else{ echo "Can't upload file!"; }// End of Upload Code } ?>














Be The First To Comment
Related Post
Please Leave Your Comments Below