Page 1 of 1

error while uploading

Posted: Fri May 15, 2009 1:43 am
by s_coder
hello,
i am getting na erroe while uploading a file. please can anyone help me out in this ? the code what i have written for it is given below :

Code: Select all

 
$file = 'C:/somefile.txt';----->my local file
$remote_file = 'readme.txt'; -->name by which it should be stored on server
 
// set up basic connection
$ftp_server="uop.demosites.info";
$ftp_user_name="demosites";
$ftp_user_pass="demosites";
$conn_id = ftp_connect($ftp_server);
 
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); 
 
// upload a file
if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
echo "successfully uploaded $file\n";
} else {
echo "There was a problem while uploading $file\n";
}
 
// close the connection
ftp_close($conn_id);

Re: error while uploading

Posted: Fri May 15, 2009 7:47 am
by mattpointblank
Looks like you're trying to upload that file to your webserver root directory - try changing $remotefile to something like:

Code: Select all

$remote_file = 'htdocs/readme.txt';  // depends on your server, but use the folder name that you put files in

Re: error while uploading

Posted: Fri May 15, 2009 11:23 am
by ldougherty
What is the actual error you are getting when you run the script?