Welcome Guest, Not a member yet? Register   Sign In
File Upload Problem - What have I missed?
#1

[eluser]ownersbox[/eluser]
I have read a ton of threads on this subject and tried everything they suggest, so far nothing has worked.

I get "The upload path does not appear to be valid."

I have an uploads directory set to 777. I have tried the directory relative and static...

Code:
var_dump($_SERVER['SCRIPT_FILENAME']);
var_dump(is_dir('/home/14081/domains/mydomain.com/html/uploads/'));
$config['upload_path'] = '/home/14081/domains/mydomain.com/html/uploads/';

I am using the same page with the uploads added as the SCRIPTS_FILENAME. The is directory check returns true. So it sees the directory, the directory is writtable but still I get the error.

Here is my upload code in the controller

Code:
var_dump($_SERVER['SCRIPT_FILENAME']);
var_dump(is_dir('/home/14081/domains/mydomain.com/html/uploads/'));
            $config['upload_path'] = '/home/14081/domains/mydomain.com/html/uploads/';
            $config['allowed_types'] = 'gif|jpg|png';
            $config['max_size']    = '100';
            $config['max_width']  = '1024';
            $config['max_height']  = '768';
        
            $this->load->library('upload', $config);
    

                if (!$this->upload->do_upload())
                {
                    $data['error'] = $this->upload->display_errors();
                    $this->load->view('layout/_header');
                    $data['login_view'] = $this->login();
                    $this->load->view('upload_form', $data);
                    $this->load->view('layout/_footer');
        }    
        else
        {
            $data = array('upload_data' => $this->upload->data());
            
            $this->load->view('upload_success', $data);
        }

Thoughts? I am on MT if that helps.
#2

[eluser]Yorick Peterse[/eluser]
Try the following upload path:

Code:
$config['upload_path'] = './uploads/';

This will upload the files to the 'uploads' directory if you structure is as following:

Code:
public_html (the root)
|
|__codeigniter
|
|__uploads
#3

[eluser]ownersbox[/eluser]
Sorry, that was the first path I tried. I just tried it again and the dir check say true, so it does see it but I still get the "The upload path does not appear to be valid."


Do I need to do something special to my routes or htaccess?
#4

[eluser]outrage[/eluser]
Depends on your htaccess.

Some htaccess files prevent access to folders/files with a line similar to this:

Code:
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)

Try adding your uploads folder to this line like so:

Code:
RewriteCond $1 !^(index\.php|uploads|images|css|js|robots\.txt|favicon\.ico)

Good luck.
#5

[eluser]ownersbox[/eluser]
I'm still getting the error but I'm not sure I have my htaccess correct
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !^(index\.php|uploads|images|css|js|robots\.txt|favicon\.ico)
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>

    ErrorDocument 404 /index.php
</IfModule>
AddHandler php5-script .php
#6

[eluser]ownersbox[/eluser]
Anyone have any thoughts on this? I have tried the three options here: http://codeigniter.com/wiki/Dreamhost_.htaccess/
#7

[eluser]Unknown[/eluser]
Hello,
Can anyone help me to resolve my issue.
I tried one sample code to upload images. But I am getting following error.
"You don't have permission to access /CodeIgniter/index.php/upload/do_upload on this server."
I have given all required permissions. Eventhough I am getting same error.
Please help me to resolve this issue. Since I am new to this frame work.

Thanks in advance.
#8

[eluser]KieranA[/eluser]
[quote author="outrage" date="1243537923"]Depends on your htaccess.

Some htaccess files prevent access to folders/files with a line similar to this:

Code:
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)

Try adding your uploads folder to this line like so:

Code:
RewriteCond $1 !^(index\.php|uploads|images|css|js|robots\.txt|favicon\.ico)

Good luck.[/quote]

fyi .htaccess doesn't effect the server locally, php ignores it - it's only when you access it through the http protocol that it kicks in.
#9

[eluser]ownersbox[/eluser]
I solved my problem - While the error I was getting was invalid path it actually was an issue with conflicting validation. Once I reverted to the original upload example it worked fine. Thank you for your help.




Theme © iAndrew 2016 - Forum software by © MyBB