Advertisement
citstudio

Upload File

Jun 21st, 2012
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.92 KB | None | 0 0
  1. [controller]
  2.  $config = array(
  3.             'upload_path'       => './resources/uploads'
  4.             , 'allowed_types'   => 'gif|jpg|png'
  5.             , 'max_size'        => '1000000000'
  6.             , 'max_width'       => '2048'
  7.             , 'max_height'      => '1024'
  8.         );
  9.        
  10.         $this->upload->initialize($config);
  11.  
  12. $pic        = '';
  13.        
  14.         if (isset($_FILES["userfile"]["name"])){
  15.             if ( ! $this->upload->do_upload()){
  16.            
  17.             }else{
  18.                 $tGambar    = $this->upload->data();
  19.                 $pic        = $tGambar["file_name"];
  20.             }
  21.         }else{
  22.             $pic        = '';
  23.         }
  24.  
  25.  
  26. [view]
  27. <?php
  28. $attributes = array('class' => 'form_container', 'id' => 'myform');
  29. echo form_open_multipart('administrator/item/do_item',$attributes);
  30. ?>
  31. <input type="file" name="userfile" id="userfile" class="file_1" />
  32. <?php echo '</form>';?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement