Search
 
SCRIPT & CODE EXAMPLE
 

PHP

codeigniter 3 image upload

<?php<?phpdefined('BASEPATH') OR exit('No direct script access allowed');
class User extends CI_Controller {
 
 public function index(){
   // load base_url  
   $this->load->helper('url');
 
   // Check form submit or not 
   if($this->input->post('upload') != NULL ){ 
      $data = array(); 
      if(!empty($_FILES['file']['name'])){ 
         // Set preference 
         $config['upload_path'] = 'uploads/'; 
         $config['allowed_types'] = 'jpg|jpeg|png|gif'; 
         $config['max_size'] = '100'; // max_size in kb 
         $config['file_name'] = $_FILES['file']['name']; 

         // Load upload library 
         $this->load->library('upload',$config); 
   
         // File upload
         if($this->upload->do_upload('file')){ 
            // Get data about the file
            $uploadData = $this->upload->data(); 
            $filename = $uploadData['file_name']; 
            $data['response'] = 'successfully uploaded '.$filename; 
         }else{ 
            $data['response'] = 'failed'; 
         } 
      }else{ 
         $data['response'] = 'failed'; 
      } 
      // load view 
      $this->load->view('user_view',$data); 
   }else{
      // load view 
      $this->load->view('user_view'); 
   } 
 }
}
Comment

PREVIOUS NEXT
Code Example
Php :: laravel datatables 
Php :: laravel one command for model table and controller 
Php :: yii2 migration --fields foreign 
Php :: compare two datetime php 
Php :: timezones php 
Php :: Try raising max_execution_time setting in php.ini file (CentOS path is /etc/php.ini): max_execution_time = 300Fix 504 Gateway Timeout using Nginx 
Php :: Add Text After or Before on the Shop Page/Archive Page 
Php :: php rce command 
Php :: cmd run php file 
Php :: @method overide form laravel 
Php :: php variable inside mysql query 
Php :: laravel transactions eloquent 
Php :: laravel move/rename file ftp 
Php :: PHP sha1 — Calculate the sha1 hash of a string 
Php :: is resource php 8 
Php :: laravel date format valdiate 
Php :: remove some state from state list woocommerce 
Php :: php file iterator 
Php :: get last name user 
Php :: php simple sse 
Php :: is search page wordpress dev 
Php :: try_files $uri $uri/ /index.php?$query_string; 
Php :: html windows logo 
Php :: custom blade directive 
Php :: laravel roles and permissions 
Php :: how does substr_compare() works PHP 
Php :: Laravel unique Validation with multiple input value 
Php :: Unable to do sum and getting same value by using while loop php 
Php :: pass the product name to form field cf7 woocommerce 
Php :: laravel route model binding 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =