1

I don't have any idea on what's wrong here:

I have tried:

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

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

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

I always get

"Unable to load the requested file: upload.php"

The Upload.php file is where it should (system/libraries) and I have no idea at all on this error. Works fine on localhost, but not on the server.

Maybe it's because CI is installed on a subdomain? For me all configs are set correctly on CI configs.

Upload.php is a CI class, and for some reason, it's not being found from a controller, and this is quite bizarre to me.

Any clues?

Antonio Max
  • 8,627
  • 6
  • 43
  • 42
  • Did you ... Create a folder at the root of your CodeIgniter installation called uploads and set its file permissions to 777? – sbeliv01 Sep 12 '13 at 16:13
  • You can check .htaccess configuration for rewrites. – Ajeet Sinha Sep 12 '13 at 16:20
  • Nice tip on .htaccess redirects, but everything's quite right there as well. As for the folder permission hint, the upload never started to no folder permission issues there. Thanks guys. – Antonio Max Sep 12 '13 at 16:56

2 Answers2

4

Ok, found the issues:

First: When trying to call an upload function on the controller, directly on the address bar, the error:

 "Unable to load the requested file: upload.php"

Is directly caused by no file being sent for the function, as I found while tailing the CI log file.

Also, for some reason, config would not work if loaded like this:

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

Had to init the config like this:

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

That was error one.

Nevertheless, my upload function wasn't working anyway. After investigating firebug console errors as I'm using angular to do the upload, I've found the second issue:

A PHP Error was encountered

Severity: Warning

Message: escapeshellarg() has been disabled for security reasons

Filename: libraries/Upload.php

So a quick search on stack overflow got me the answer:

$cmd = 'file --brief --mime ' . @escapeshellarg($file['tmp_name']) . ' 2>&1';

Open Upload.php file from system/libraries folder and put @ in front of escapeshellarg($file['tmp_name']) at line 1066 and second thing upload this file under application/libraries folder that will be better, other wise no problem, you can replace system's Upload.php file

As in escapeshellarg() has been disabled for security reasons

So I have manually updated the upload.php file and voilá.

After all, upload.php needed a patch for a server setup incompatibility. Thanks everyone.

Community
  • 1
  • 1
Antonio Max
  • 8,627
  • 6
  • 43
  • 42
0

I've found (on Linux) there's sometimes loading issues if your filename starts with an uppercase, but you try and load using lowercase, or vice-versa (I can't remember if this was with libraries or not).

Also make sure you have class Upload and not class upload

olimortimer
  • 1,373
  • 10
  • 23
  • Indeed, I've seen that before, but this was happening to a default CI class, not a custom one, so by all means, it was supposed to work by default. – Antonio Max Sep 12 '13 at 16:57