With many forms you may want to include some sort of upload of a file. There are many functions for files in PHP that you can use to do this.
Some things you may want to consider when uploading a file to your server:
- File extension – what type of file is being uploaded.
- File size – How big is the file, should the be a limit?
- What to do on a successful upload.
Here is a basic form uploading to the file “upload.php”.
[code lang=”html”]
[/code]
Now on upload.php we need to have code that reacts to this form being submitted, other wise nothing will happen obviously.
[code lang=”php”][/code]
That would be our code for upload.php. When the form is submitted it will execute that code and perform the upload as long as it passes the tests.
You can specify any directory, extensions, filesize limit you want of course. Enjoy.