CodeIgniter Forums
Upload Path invalid on upload - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: Upload Path invalid on upload (/thread-75573.html)



Upload Path invalid on upload - murugappan - 02-22-2020

Hi,

I am new to codeigniter and undergoing a course in Udemy. I tried the upload library and i seem to have a problem with the 'upload_path' parameter. It always gives me an "invalid path" error. I have attached the screen caps of the code.

Greatly appreciate if anyone can help me with this.
Thank you in advance.


RE: Upload Path invalid on upload - jreklund - 02-23-2020

Hi, wrap it with realpath().

PHP Code:
realpath(APPPATH.'../assets/images/'); 



RE: Upload Path invalid on upload - dave friend - 02-23-2020

I suggest building the upload path like this

PHP Code:
$config['upload_path'] = FCPATH 'assets/images/'

FCPATH is the path to the folder where CI's index.php is found.

An alternate way to build the path is this.

PHP Code:
$config['upload_path'] = str_replace('application''assets/images'APPPATH); 

I don't think either one is clearly superior, but the first is the simplest. That's good, right?

jrekland's answer works too, but be aware that it won't include a trailing slash because realpath() removes trailing delimiters. I cannot remember if a trailing slash is important in this use-case or not.


RE: Upload Path invalid on upload - murugappan - 02-23-2020

Hi Guys,

Thank you for all the help. Great to see such good response. I tried all the suggestion but got the same results. Then after some digging, i found that this happens when the "upload" is autoloaded in the autoload.php file. I removed it and it works fine.