I’ll start from top to bottom on the coding. A few random notes first:
- This must be a PHP file type (.php).
- The max file limit isn’t defined so your host will define this (default is 2MB).
- There is no file restriction check in this version.
- Do not copy the code from this post and paste it straight into dreamweaver as it will read the single quotes incorrectly and give you errors in the PHP.
Now to break it down into sections. First the Form section which is a pretty standard looking HTML form:
- You can change the word “file” for anything you’d like except for the input type.
- Divs were used just to break up the upload form as well as leaving the option to add id or class to them for some CSS styling.
So this is the HTML to make the form users will see and be able to use.
Now lets make this simple form actually do something, here’s the PHP that actually makes the form work:
Line 4 – Defines where the file will be uploaded to on your server space.
Line 6 – Gives the file a new name.
Line 7 – Uploads the file with the new name to the directory.
Here are all the files you’ll need get this running all you’d have to do is upload the zipped files and point a URL to it or place it into a sub folder.