Posts Tagged image upload

CodeIgniter image upload

When I first time try to write code for image upload on Codeigniter, I had to face problems. I dig and dig and dig. I search on CI guide. but, thats not enough to help me. Well, finally I did it.  If someone stuck on CI image upload, hope it will help them a lot.

There are some easy steps to upload image on CI :

  • Create the form normally how it should create for upload a photo on php.  Must add “enctype=”multipart/form-data”
  • open controler file. under the upload image function write down following code :
  • $config[ 'upload_path' ] =  ‘./uploads/’ ;  // destination folder path
  • $config[ 'allowed_types' ]  =  ‘gif|jpg|png’ ; // Allowed uploaded file type
  • $config[ 'max_size' ]    =  ‘2048′ ;// Allowed uploaded file’s max size
  • $this->load->helper( array(  ‘form’ ,  ‘url’ ) ) ;
  • $this->load->library( ‘upload’ ,  $config);
  • $image_up = $this->upload->do_upload(‘image‘);
  • $image_data =  array(‘upload_data’ => $this->upload->data());
  • $image_up is where image upload information will be safe, it will return 1 if image uploaded successfully.
  • $config is very important variable. for details of  “$config” variable’s parameters  you must have to see the manual
  • $image_data will carry the uploaded image information.
  • BLUE marked words are library function.
  • image is form name

Add comment July 24, 2009


My Profile


# Software Eng. # Worked with C,C++, JAVA and PHP. #Love to play with codes. # Mostly like to do programming with 'C'. # I am not a CODER, but a DEVELOPER.

Admin Panel..

Life Cycle

December 2009
S S M T W T F
« Sep    
 1234
567891011
12131415161718
19202122232425
262728293031  

Clouds

cakephp codeIgniter desktop htaccess jscript linux mixed my words php regular expression

Just Posted

TOP R@TED

TaGs

cakephp codeIgniter desktop GP htaccess image upload installation jscript linux news password Personal Life php regular_Xpression script session validation

Archives

Top Posts

CoMmEnTs

Blog Stats

My Web Links

Web Links

RSS Xperts.PHP