In lesson nine of our CodeIgniter series, we’ll build a small image gallery that allows you to upload files, and automatically create thumbnails.
Catch Up
- Day 1: Getting Started With the Framework
- Day 2: Database Selecting Methods
- Day 3: Sending Emails
- Day 4: Newsletter Signup
- Day 5: CRUD
- Day 6: Login
- Day 7: Pagination
- Day 8: AJAX
- Day 9: File Uploading and Image Manipulation
Day 9: File Uploading and Image Manipulation
Other Viewing Options
- Follow us on Twitter, or subscribe to the Nettuts+ RSS Feed for more daily web development tuts and articles.


After i have chosen file and choose upload a particular image file. It works fine. However, when i refresh the page, the same image will be added to the gallery again. Is there a bug for the source code?
@Lew , thats not a bug , the same thing would happen if you were using core php. you need to add code that checks if the submit button was pressed before allowing an upload such as
if(isset($_POST['btn'])
{
//do upload
}
when you refresh the last action is executed but when you have a button that needs to be pressed it wont.
this error in my code,
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Gallery_model::$upload
Filename: models/gallery_model.php
Line Number: 23
Fatal error: Call to a member function do_upload() on a non-object in C:\xampp\htdocs\Age\application\models\gallery_model.php on line 23
line 23//$this->upload->do_upload();
Great tutorial, thanks!
I got it working with one difference:
I have my images folder in a different location, ie I have
system/
application/
public_html/images/
I used $this->gallery_path = realpath(FCPATH . ‘/images’);
(Instead of APPPATH)
Great post. Thanks.
can anyone help, how can i download file from the server using the codeigniter? plz i need help