error while uploading

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
s_coder
Forum Newbie
Posts: 8
Joined: Thu May 14, 2009 4:59 am

error while uploading

Post 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);
Last edited by Benjamin on Fri May 15, 2009 8:25 am, edited 1 time in total.
Reason: Added [code=php] tags.
mattpointblank
Forum Contributor
Posts: 304
Joined: Tue Dec 23, 2008 6:29 am

Re: error while uploading

Post 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
Last edited by Benjamin on Fri May 15, 2009 8:26 am, edited 1 time in total.
Reason: Added [code=php] tags.
ldougherty
Forum Contributor
Posts: 103
Joined: Sun May 03, 2009 11:39 am

Re: error while uploading

Post by ldougherty »

What is the actual error you are getting when you run the script?
Post Reply