Page 1 of 1
The code below for ftp upload from remote machine to server
Posted: Wed Jan 31, 2007 12:07 am
by basudeb
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I just use this code to upload a file from my remote machine($source_file ) to the specific server.
But this code is ok upto the $login_result .
When it execute the function ftp_put it gives the "Error";
Give me a suggestion regarding the error message..
Code: Select all
<?php
$server = 'SERVER_NAME'; //changed for this example
$user = 'USER_NAME'; //changed for this example
$pass = 'PAEEWORD'; //changed for this example
$source_file = 'E:FOLDER:FILE_NAME';
$destination_file ='DESTINATION_FOLDER';
// set up basic connection
$conn_id=ftp_connect($server);
//echo ftp_pwd($conn_id);
// login with username and password
$login_result = ftp_login($conn_id, $user, $pass);
$abc=ftp_put($conn_id, $destination_file, $source_file, FTP_ASCII) or die("Error");
// close the connection
ftp_close($conn_id);
?>
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Posted: Wed Jan 31, 2007 12:48 am
by gavin1996
ftp_login is a Object????
The code below for ftp upload from remote machine to server
Posted: Wed Jan 31, 2007 3:37 am
by basudeb
1) No, here the ftp_login is the php in-built function. which is used to ftp login with a server.
2) I want to use FTP file/ Folder Uploading not any HTTP uploading.
3) So i also wanna know wheather is it possible to ftp uploading(file/folder) from a remote
client machine(as C:/documents/img.jpg) to a connected server ?
4) If possible then how?
5) Can any body post me the exact PHP code ?
Thanks
Posted: Wed Jan 31, 2007 3:52 am
by gavin1996
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
folder??? that's difficile/
try :
Code: Select all
<?php
$handle=opendir('.'); //input path
echo "folder handle: $handle\n";
echo "file:\n";
while ($file = readdir($handle)) {
echo "$file\n";
// upload file code .........
}
closedir($handle);
?>
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
The code below for ftp upload from remote machine to server
Posted: Wed Jan 31, 2007 4:17 am
by basudeb
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I just use this code to upload a file from my remote machine($source_file ) to the specific server.
But this code is ok upto the $login_result .
When it execute the function ftp_put it gives the "Error";
Give me a suggestion regarding the error message..
Here the ftp_login is the php in-built function. which is used to ftp login with a server.
I want to use FTP file/ Folder Uploading not any HTTP uploading.
So i also wanna know wheather is it possible to ftp uploading(file/folder) from a remote
client machine(as C:/documents/img.jpg) to a connected server ?
If possible then how?
Can any body post me the exact PHP code ?
Code: Select all
<!!----------This is my code ----------------!!!!!!!!>
<?php
$server = 'SERVER_NAME'; //changed for this example
$user = 'USER_NAME'; //changed for this example
$pass = 'PAEEWORD'; //changed for this example
$source_file = 'E:FOLDER:FILE_NAME';
$destination_file ='DESTINATION_FOLDER';
// set up basic connection
$conn_id=ftp_connect($server);
//echo ftp_pwd($conn_id);
// login with username and password
$login_result = ftp_login($conn_id, $user, $pass);
$abc=ftp_put($conn_id, $destination_file, $source_file, FTP_ASCII) or die("Error");
// close the connection
ftp_close($conn_id);
?>
Thanks
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Posted: Wed Jan 31, 2007 4:24 am
by gavin1996
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Code: Select all
<?php
$ftp_server = "ftp.example.com";
$ftp_user = "foo";
$ftp_pass = "bar";
// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
echo "Connected as $ftp_user@$ftp_server\n";
} else {
echo "Couldn't connect as $ftp_user\n";
}
?>
But..... is there exist a FTP server on your website Server????
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Posted: Wed Jan 31, 2007 4:52 am
by basudeb
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Code: Select all
<?php
$ftp_server = "ftp.example.com";
$ftp_user = "foo";
$ftp_pass = "bar";
// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
echo "Connected as $ftp_user@$ftp_server\n";
} else {
echo "Couldn't connect as $ftp_user\n";
}
?>
Yes when i use your code its ok amd shows me the message "Connected as $ftp_user@$ftp_server\n".
Upto that my code is also ok.. Now when i entire the ftp_put it doesn't work.
It gives the "ERROR"
I also give my code .
Code: Select all
<?php
$source_file = 'E:FOLDER:FILE_NAME';
$destination_file ='DESTINATION_FOLDER';
$abc=ftp_put($conn_id, $destination_file, $source_file, FTP_ASCII) or die("Error");
// close the connection
ftp_close($conn_id);
?>
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Posted: Wed Jan 31, 2007 8:10 am
by feyd
You two need to start using the formatting tags.