Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

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:
  • 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
The winner will be chosen with the following criteria:
  • 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
If you cannot write PHP yet, here's what you could Google to learn how to do this...
  1. How to create a PHP file / upload to host
  2. Start / end a PHP file (tags)
  3. Analyze $_FILES array from a form
  4. Verify file size, type / error reporting
  5. Make sure file upload cannot be exploited / secure file upload
  6. Check if file exists / create unique file name
  7. Error codes for $_FILES array, upload file / move file
  8. Success / error messages with JSON
  9. OR redirecting to a success/error message page
If you can look up those concepts, you can complete this challenge. May the best PHP-er win!
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom