uploading image in codeigniter controller

uploading image in codeigniter controller

Content Index :

uploading image in codeigniter controller
Tag : php , By : Bart van Bragt
Date : November 23 2020, 01:01 AM

Hope that helps i'am not able to do upload image with lines of code in function add()
   $config = array(
        'upload_path'   =>  'uploadPath',
        'allowed_types' =>  'jpg,jpeg',
        'max_size'      =>  1500

    $this->load->library('upload', $config);

        if(isset($_FILES['field_name']) && $_FILES[field_name]['name'] != NULL)

              $upload_data = $this->upload->data();

                $data_to_insert = array(
                    'attachment_link'   => 'uploadPath/'.$upload_data['file_name'],
                    'attachment_size'   => $upload_data['file_size']
                     // u can add parameters as for ur table to save



               echo $this->upload->display_errors();


No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

CodeIgniter - Uploading an Image through a form, store the location of the image in database

Tag : php , By : John Phipps
Date : March 29 2020, 07:55 AM
help you fix your problem CodeIgniter's file uploading class will do this for you. The entry in their user guide explains as well as I could, so I'm going to point you there.
Essentially you'd just need to modify the controller that they have there to include a bit where you put the file URL in the database, which you can accomplish easily by using $this->upload->data() and extracting [full_path] from the resulting array, and then sending it to a model which handles the database input.

error while uploading codeigniter 3 on godaddy .only the default controller is working

Tag : codeigniter , By : Frank
Date : March 29 2020, 07:55 AM
like below fixes the issue I am using codeigniter version 3. It's working absolutely fine in localhost, but when I am trying to upload this to godaddy server ,only default controller is working. Please anyone suggest the necessary configuration changes. I tried changing the .htaccess file but not working. , Working configuration on my godaddy server.
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
# Default
$route['default_controller'] = "home";
$config['base_url'] = '';
$config['index_page'] = '';

When uploading image in codeigniter the image is not saved into the path folder

Tag : php , By : Deepak Poondi
Date : March 29 2020, 07:55 AM
I hope this helps you . I found the answer and posted the code, in case anyone else wants to look at this...
the 'view'
 <div id="timelineBackground">


    $image_properties = array('src' => base_url("uploads/" . $timeline_image),'width' => '1000px','height'=> '400px','id'=>'coverimg', 'title' => 'That was quite a night','rel'   => 'lightbox');
 echo img($image_properties);

<div id="timelineselector">

<?php echo form_open_multipart('user/coverimage',["id"=>"form_cover"]); ?>
<input type="hidden" name="id" value="<?php echo $id ;?>" >

<?php echo form_upload(["name"=>"timelineimage"]); ?>

<?php echo form_submit(["name"=>"submit","value"=>"Submit"]); ?>

<?php echo form_close(); ?>




        var formData = new FormData(this);
        var url= '<?php echo base_url("user/coverimage"); ?>';

            type: "POST",
            data: formData,
            cache: false,
            contentType: false,
            processData: false,
            success: function(data)

            error: function(data){
            //error function
     public function coverimage()

      $config = [
                  'upload_path' =>    './uploads/',
                  'allowed_types' =>    'jpg|gif|png|jpeg',
                  'max_size'            => 10000000000000,
                  'max_width'            => 1024000000,
                  'max_height'           => 7680000000,
              $this->load->library('upload', $config);
          $upload_error = $this->upload->display_errors();


            $post = $this->input->post();

          $upload_data = $this->upload->data();


         $image_path= base_url("uploads/".$upload_data['raw_name'].$upload_data['file_ext']);

//echo base_url("uploads/" . $file_name['name']);



Resize image in CodeIgniter while uploading and save that resized image in directory

Tag : php , By : Mena
Date : March 29 2020, 07:55 AM
With these it helps Create a helper function. And call helper function with the uploaded image file path. It will replace your image with the new size.
public function submitd()
         $config['upload_path'] = './images';
         $config['allowed_types'] = 'gif|jpg|png|jpeg';
           $filedata = $this->upload->data();
//you can create this function in helper or in same controller.
function resize_image($file_path) {
  $CI =& get_instance();
    // Set your config up
    $config['image_library']    = "gd2";      
    $config['source_image']     = $file_path;      
    $config['create_thumb']     = TRUE;      
    $config['maintain_ratio']   = TRUE;     
    $config['new_image'] = $file_path; 
    $config['width'] = "320";      
    $config['height'] = "240";  

    // Do your manipulation



Image uploading using codeigniter file uploading class

Tag : image , By : user185751
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • axios and vuex are deleting wrong index in array
  • Setting empty CURLOPT_POSTFIELDS
  • Laravel 5.8 use subdomain as API endpoint beside domain.com/api
  • Error while add data in database SQL Server 2016
  • Does PhpStorm allow to skip PHPDoc tags when type hints is declared?
  • html classes are changed to Attributes
  • Using json to import multidimensional data
  • passing data from the view to the controller, where the data comes from another controller
  • How to extract integer and decimal numbers in PHP string correctly?
  • Parsing Sub-Object from an XML Feed with objects
  • Getting error "Unknown column 'text' in 'field list'"
  • How to properly get onedrive access token via php and curl
  • How to add spell check to a php function
  • Is it posible to create css rules with php?
  • Pretty URL with $_GET method
  • Wordpress always load same page - index.php
  • Find value in array and return with new from different array
  • PHP multiple file upload with different keys
  • Can't modify times one a time without weird errors
  • Get size of scraped image with domcrawler (Goutte)
  • Laravel - Ordering a collection of models
  • PHP Fatal error: Uncaught Error: Call to a member function setFetchMode() on boolean
  • Strict Standards: Only variables should be passed by reference in /main_dir/sub_dir/backup.php
  • Uncaught Google_Exception: (update) unknown parameter: 'copyRequiresWriterPermission'
  • Laravel 5 form does not redirect with old input
  • How to get values greater than or equal to in Mysql database sql when its a value like 1:00 PM?
  • PHP datediff overday issue
  • Masking an auto incrementing primary key
  • How to grab a String BEFORE a certain word
  • ZF2 Routing Multiple Controllers based on route constraints
  • How to deregister/dequeue jquery.sticky.js in Elementor (Pro)?
  • How to fix errors counting words in text plain with PHP?
  • How to get View data in Laravel in custom helper or directive
  • Creating a new data entry into a database with eloquent and trying to access the variable in the url
  • How to test authentication using Laravel Dusk?
  • PHP parse_str not getting all $_GET variables
  • Variable issues in php class
  • Get orders between dates in Codeigniter
  • Eloquent Special Chars Issue
  • Keeping leading zeros column Mysql
  • Current level navigation in Wordpress
  • Add a custom text to WooCommerce cart items if the product has a specific shipping class
  • Error connecting to CommissionJunction Token : [60] SSL certificate problem: unable to get local issuer certificate
  • How do I add a new key value pair to an object in PHP?
  • Http post request to php with dart
  • How to add a route in with blade into parameters of a component
  • How can i get the source of a 777 - CHMOD php file?
  • Convert 2010-04-16 16:30:00 to "Tomorrow Afternoon"
  • How can I hide a $_GET variable to be more secured in PHP?
  • Login to Gmail Inbox using Curl?
  • Upload Excel or CSV file to MySQL with PHP
  • Outlook Marking Email as Junk Email
  • Upload an image using class.upload.php via AJAX, display image in form using jQuery
  • mysql_connect() causes page to not display (WAMP)
  • How to limit a users uploaded image size using PHP
  • What's the difference whether or not to run PHP in safe mode?
  • Logging in to a website cURL
  • Using php to create a password system with chinese characters
  • PHP is not called properly in IE using set interval function in Javascript
  • How to read pdf, ppt, xl, doc files content into a string in php/python
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com