Re: Uploading file into ftp server
Posted: Sun Jul 24, 2011 3:27 pm
Before, you said you were able to upload logo.png. What changed?
Yes before I uploaded an image but from my local PC and not from live server to another:
Here is the code I used to do that (from my PC):
<?php
//Send the FTP Connection and send the Excel file to the ftp server
$ftp_server = "xxx";
$ftp_user = "xxx";
$ftp_pass = "xxxx";
$file = 'file:///C:/Users/Youssef/Desktop/logo.png';
$fp = '/hello.png';
// set up a connection or die
$conn_id = ftp_connect($ftp_server , 20) 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";
}
ftp_pasv ($conn_id, true);
if (ftp_put($conn_id, $fp, $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);
?>
Yes before I uploaded an image but from my local PC and not from live server to another:
Here is the code I used to do that (from my PC):
<?php
//Send the FTP Connection and send the Excel file to the ftp server
$ftp_server = "xxx";
$ftp_user = "xxx";
$ftp_pass = "xxxx";
$file = 'file:///C:/Users/Youssef/Desktop/logo.png';
$fp = '/hello.png';
// set up a connection or die
$conn_id = ftp_connect($ftp_server , 20) 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";
}
ftp_pasv ($conn_id, true);
if (ftp_put($conn_id, $fp, $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);
?>