Join Jon Peck for an in-depth discussion in this video Uploading images with the File Uploading class, part of Learning PHP CodeIgniter (2013).
File uploads can be a pain, but CodeIgniter tries to eliminate some of the…more obnoxious parts using the file uploading class which is especially…helpful for images. File uploads consist of the following process.…First, the file form element is displayed to the user.…Then, the form is submitted and the file is uploaded.…Based on file upload preferences such as image height, width or maximum size, the…file is validated. When validation is past, the file metadata…is available for use. I'm going to allow users to upload cover…images of the back issues. First, switch to a terminal and navigate…to the root directory of your CodeIgniter installation, verify that you're in the…right place. Next, make a directory that you can use to…upload files to. Mkdir, space, upload.…
Next, set the permissions on that directory.…Chmod 755 is a best practice. In a worst-case scenario, use 777 but this…is almost never necessary and not recommended, as it's a big security risk.…Now that the designation exists, I can go back to the IDE.…
Starting with the what and why of CodeIgniter, Jon introduces key concepts such as the MVC pattern and libraries by demonstrating how to create static pages, then storing and displaying magazine info in a database. Advanced topics like classes and helpers are explored to validate user input, upload files, and much more. By creating a complete system, you'll have the foundation to build your own applications with CodeIgniter.
- What is CodeIgniter?
- Creating a static page controller
- Generating output with a view
- What is a model?
- Saving data with Active Records
- Creating forms
- Validating user input
- Listing records in tables
- Uploading images
- Viewing and deleting records