Ghost
Platinum Coder
I have decided to start a mini coding challenge.
This challenge should be fairly simple to an experienced PHP coder, but may be hard for some. File uploading is very common in PHP based projects, so if you don't know how - learn! and compete
You must:
This challenge should be fairly simple to an experienced PHP coder, but may be hard for some. File uploading is very common in PHP based projects, so if you don't know how - learn! and compete
You must:
- take a FILE from $_FILES (form file upload array)
- Save it to the /uploads/ folder
- The file name cannot exist already
- You must upload the file & allow it to be accessed SECURELY
- Max file size is 10 MB
- File types allowed: pdf, doc, docx, png, jpg, jpeg, gif
- Echo out a response such as "Your file has been uploaded successfully" OR redirect somewhere (ex: file-upload-successful.html)
- You do not have to create any HTML. PHP only
- Clean code
- Secure upload
- Efficient code
- The PHP code must work flawlessly from an HTML form with a normal file upload field
- Comments explaining what is happening
- Proper error messages / handling
- Proper success message / handling
- How to create a PHP file / upload to host
- Start / end a PHP file (tags)
- Analyze $_FILES array from a form
- Verify file size, type / error reporting
- Make sure file upload cannot be exploited / secure file upload
- Check if file exists / create unique file name
- Error codes for $_FILES array, upload file / move file
- Success / error messages with JSON
- OR redirecting to a success/error message page