1
votes

i need to upload a zip from my localhost to my webserver with my codeigniter application. I have followed the docs but i can't upload file, the error is:

An Error Was Encountered

Unable to locate the source file. Please check your path.

i can't figured out why it can't find the source path, if i try to test the path with file_exists it work, but with the upload method fails...

This is my code:

$this->load->library('ftp');

$config_ftp['hostname'] = 'xxxxx';
$config_ftp['username'] = 'xxxxx';
$config_ftp['password'] = 'xxxxx';
$config_ftp['debug']    = TRUE;

$this->ftp->connect($config_ftp);

if(file_exists($my_file))
    echo "ok";
else
    echo "no";

$this->ftp->upload($my_file , '/web/'.$my_file, 'binary');
1
If you use the FCPATH constant, this will provide you the Path that contains the bootstrap index.php. From there, you can build the path to the file you want to upload. - Gavin
Can you show the contents of $my_file? Also try using absolute path if you're not doing that already. - Robert
With FCPATH i get the path from the localhost: /Applications/MAMP/htdocs/AllWorks/Giovanetti2012/gestionale/ at this i have append the $my_file that contains the path from the gestionale folder to the zip file and the new path is: /Applications/MAMP/htdocs/AllWork/Giovanetti2012/gestionale/files/xml/auto/archive.zip but it doesn't work - Christian Giupponi
Did you check the file permissions on the folder / file? - Robert
Yes, i have all the permission...by now i use the ftp function here: http://php.net/manual/en/book.ftp.phpand it works! - Christian Giupponi

1 Answers

0
votes

I have used the standard php function for the ftp and now it works