Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8255333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:29:18+00:00 2026-06-08T01:29:18+00:00

I have to upload a base64 encoded image that i am receiving from android

  • 0

I have to upload a base64 encoded image that i am receiving from android application. I am using php codeigniter framework.
While searching through the forum, the question at this link How to upload base64encoded image in codeigniter is same as mine, but the solution there is not working for me.

Here is the code that i have written:

private function _save_image() {
    $image = base64_decode($_POST['imageString']);
    #setting the configuration values for saving the image
    $config['upload_path'] = FCPATH . 'path_to_image_folder';
    $config['file_name'] = 'my_image'.$_POST['imageType'];
    $config['allowed_types'] = 'gif|jpg|jpeg|png';
    $config['max_size'] = '2048';
    $config['remove_spaces'] = TRUE;
    $config['encrypt_name'] = TRUE;


    $this->load->library('upload', $config);
    if($this->upload->do_upload($image)) {
        $arr_image_info = $this->upload->data();
        return ($arr_image_info['full_path']);
    }
    else {
        echo $this->upload->display_errors();
        die();
    }
}

I am getting “you did not select a file to upload”

Thanks for your time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T01:29:19+00:00Added an answer on June 8, 2026 at 1:29 am

    The error is occurring because codeigniter’s upload library will look into the $_FILES superglobal to and search for a index you give it at the do_upload() call.

    Furthermore (at least in version 2.1.2) even if you would set up the $_FILES superglobal to mimic the behaviour of a file upload it wouldn’t pass because the upload library uses is_uploaded_file to detect exacly that kind of tampering with superglobals. You can trace the code in system/libraries/Upload.php:134

    I’m afraid that you will have to re-implement size checking and file renaming and moving (I would do this) or you can modify codeigniter to omit that check, but it could make upgrading the framework later difficult.

    1. Save the $image variable’s content to a temporary file, and set up the $_FILES to look like this:

       $temp_file_path = tempnam(sys_get_temp_dir(), 'androidtempimage'); // might not work on some systems, specify your temp path if system temp dir is not writeable
       file_put_contents($temp_file_path, base64_decode($_POST['imageString']));
       $image_info = getimagesize($temp_file_path); 
       $_FILES['userfile'] = array(
           'name' => uniqid().'.'.preg_replace('!\w+/!', '', $image_info['mime']),
           'tmp_name' => $temp_file_path,
           'size'  => filesize($temp_file_path),
           'error' => UPLOAD_ERR_OK,
           'type'  => $image_info['mime'],
       );
      
    2. Modify the upload library. You can use codeigniter’s built in way of Extending Native Libraries, and define a My_Upload (or your prefix) class, copy-paste the do_upload function and change the following lines:

      public function do_upload($field = 'userfile')
      

      to:

      public function do_upload($field = 'userfile', $fake_upload = false)
      

      and the:

      if ( ! is_uploaded_file($_FILES[$field]['tmp_name']) )
      

      to:

      if ( ! is_uploaded_file($_FILES[$field]['tmp_name']) && !$fake_upload )
      

      and in your controller, call do_upload() with the flowing parameters:

      $this->upload->do_upload('userfile', true);
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple application which sends an image (Base64 encoded) to a server,
I have to send a byte array (encoded photo) from my PHP client to
I have a simple form that uploads an image to a database. Using a
I want to upload the image using the .NET webservices and that will be
I'm having a stump with some PHP... I have a Flash Application that sends
I'm curious how to upload file through FTP using PHP. Let's say I have
I have some problem for decoding image data from base 64 encoded string. I
A thought experiment: You have a CMS that allows users to upload an image,
I need to upload an image from a rails form using Ajax and convert
I have an upload box... <form action=upload_file.php method=post enctype=multipart/form-data><BR> <label for=file>Filename:</label><BR> <input type=file name=file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.