How to upload files in php?

Hi In this tutorial we will learn how to upload files on remote server using a Simple HTML form and PHP. You can upload any kind of file like images, videos, ZIP files, documents, PDFs, as well as executable files and a wide range of other file types.

The following HTM code below creates an uploader form. This form is having method attribute set to and enctype attribute is set to multipart/form-data

Processing the uploaded file:
Now all we have to do is call the move_uploaded_file function and let PHP do its magic. The move_uploaded_file function needs to know
1) The path of the temporary file (check!)
2) The path where it is to be moved to (check!).

If the upload is successful, then you will see the text “The file filename has been uploaded”. This is because move_uploaded_file returns true if the file was moved, and false if it had a problem.

If there was a problem then the error message “There was an error uploading the file, please try again!” would be displayed.

Updated: August 6, 2016 — 9:46 pm

Leave a Reply

Your email address will not be published.

prabaweb.in Codelab- programming blog © 2017