Welcome Guest, Not a member yet? Register   Sign In
"The upload path does not appear to be valid" - Aaaargh
#1

[eluser]invision[/eluser]
On my own server I can upload files correctly to my uploads directory on the root. But not on this new server (FastHosts).

I've tried the basic here: http://ellislab.com/codeigniter/user-gui...ading.html and I can't seem to upload a file.

Each time I try I get : The upload path does not appear to be valid.

I'm using this as my:
Code:
$config['upload_path'] = 'uploads/';
and when I do

Code:
var_dump(is_dir('uploads/'));

it returns true, so does definitely exist.


Please help. I've no idea what to try now Sad
#2

[eluser]WanWizard[/eluser]
After the line that produces this error, add:
Code:
echo $this->upload->upload_path;

The validate_upload_path() method of the Upload library converts relative paths to absolute paths. It might be that it is converted to another path than you think...
#3

[eluser]invision[/eluser]
Thanks for the reply.
When I add that, I don't get anything in response. Is that odd?

excerpt...

Code:
if ( ! $this->upload->do_upload())
        {
            $error = array('error' => $this->upload->display_errors());
            echo $this->upload->upload_path;
            $this->load->view('upload_form', $error);
        }    
        else
        {
            $data = array('upload_data' => $this->upload->data());
            
            $this->load->view('upload_success', $data);
        }
#4

[eluser]WanWizard[/eluser]
Change it to
Code:
echo "[",$this->upload->upload_path,"]";
It might be that your upload path is empty, in which case you have to check if your config file is processed properly.
#5

[eluser]invision[/eluser]
Hi again.

The output is now:
[]

So does that mean it is empty?

This is my full Upload controller:

Code:
<?php

class Upload extends Controller {
    
    function Upload()
    {
        parent::Controller();
        $this->load->helper(array('form', 'url'));
    }
    
    function index()
    {    
        $this->load->view('upload_form', array('error' => ' ' ));
    }

    function do_upload()
    {
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size']    = '1000';
        $config['max_width']  = '1024';
        $config['max_height']  = '768';
        
        $this->load->library('upload', $config);
    
        if ( ! $this->upload->do_upload())
        {
            //$error = array('error' => $this->upload->display_errors());
            echo "[",$this->upload->upload_path,"]";
            $this->load->view('upload_form', $error);
        }    
        else
        {
            $data = array('upload_data' => $this->upload->data());
            
            $this->load->view('upload_success', $data);
        }
    }    
}
?>
#6

[eluser]WanWizard[/eluser]
Weird indeed.

With that $config the library loads without problems here. A call to $this->upload->validate_upload_path() returns FALSE (my dev system doesn't have a directory upload), but the value of upload_path is unaltered.

If I replace upload_path by a single dot (current dir, which is always valid), after a call to validate_upload_path() it is changed to the docroot (the directory with the index.php file). Is your upload directory a sub directory in the root?
#7

[eluser]invision[/eluser]
The upload directory is in the root itself:

Code:
/application/
/includes/
/uploads/
#8

[eluser]WanWizard[/eluser]
Do you have PHP errors enabled? If not, check your webserver log for any error messages. Something else might be wrong.
#9

[eluser]invision[/eluser]
I've got my webserver log displaying errors, but none are relating to this.

I've spoke to the host, hope to hear back soon.

Failing that, we'll have to look elsewhere.

I will let you know how it goes.



Thank you for your help
#10

[eluser]vitoco[/eluser]
try to get the full path..
Code:
echo  '['.realpath( $config['upload_path'] ).']';

if you get '[]', try to use APPPATH to create you upload_path.




Theme © iAndrew 2016 - Forum software by © MyBB