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

  • SEARCH
  • Home
  • 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 8685329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:32:26+00:00 2026-06-12T22:32:26+00:00

I’m working on uploading photos from my computer to the server, using this repository

  • 0

I’m working on uploading photos from my computer to the server, using this repository. When I try to upload a file called mylogo.jpg, I get an error that says:

Could not open file for reading: /tmp/php0d4X5Ny/mylogo.jpg

I need to figure out why I’m getting this error.

Here’s my code from the controller (cloudfiles.php):

        public function add_local_file()
        {
                $file_location = $_FILES['userfile']['tmp_name'].'/';
                $file_name = $_FILES['userfile']['name'];

                $this->cfiles->do_object('a', $file_name, $file_location);

                $this->_show_errors('Image Added!');
        }

The do_object function is here (line 151). And here is the upload view:

<?php echo form_open_multipart('cloudfiles/add_local_file'); ?>

<input type="file" name="userfile" size="20" />

<input type="submit" value="upload" />

<?php echo form_close(); ?>

I searched the cloudfiles library and found that the “could not open file for reading” error is an exception in this function:

function load_from_filename($filename, $verify=true)
    {
        $fp = @fopen($filename, "r");
        if (!$fp) {
            throw new IOException("Could not open file for reading: ".$filename);
        }

        clearstatcache();

        $size = (float) sprintf("%u", filesize($filename));
        if ($size > MAX_OBJECT_SIZE) {
            throw new SyntaxException("File size exceeds maximum object size.");
        }

        $this->_guess_content_type($filename);

        $this->write($fp, $size, $verify);
        fclose($fp);
        return True;
    }

I’ve been looking at this for several hours and can’t see what’s going wrong. Not seeing any php errors, by the way, just the one error noted above. New to Stack Overflow (frequent browser, new account), so thanks in advance for your help.

  • 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-12T22:32:28+00:00Added an answer on June 12, 2026 at 10:32 pm

    I don’t think you understand how the $_FILES array works. Once the file is uploaded, it is located at $_FILES['userfile']['tmp_name'] and does not have it’s original name.

    If you want the file uploaded with it’s original name, you will need to do something like:

    public function add_local_file()
    {
        $file_location = '/tmp/';
        $file_name     = $_FILES['userfile']['name'];
    
        if(move_uploaded_file($_FILES['userfile']['tmp_name'], $file_location . $file_name)){
    
            $this->cfiles->do_object('a', $file_name, $file_location);
    
        }
    
        $this->_show_errors('Image Added!');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
Does anyone know how can I replace this 2 symbol below from the string
I am using Paperclip to handle profile photo uploads in my app. They upload
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.