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);
?>
Uploading file into ftp server
Moderator: General Moderators
-
YoussefSiblini
- Forum Contributor
- Posts: 206
- Joined: Thu Jul 21, 2011 1:51 pm
Re: Uploading file into ftp server
I think the destination server is misconfigured--as far as PHP is concerned. The FTP server should be accepting connections on port 21 and transferring data through port 20. Instead, it accepts connections on port 20 and transfers data through an arbitrary port. This I confirmed by using the FileZilla FTP client and the Wireshark packet analyzer. I successfully uploaded a sample text file using FileZilla, but was unable to do so with PHP's FTP functions. That suggests that, while FileZilla handles arbitrary ports, the PHP FTP functions do not.
-
YoussefSiblini
- Forum Contributor
- Posts: 206
- Joined: Thu Jul 21, 2011 1:51 pm
Re: Uploading file into ftp server
OK, what I am trying to do is,
I have an e-commerce website, when a buyer buy a product it create an excel file for him in my local website and send that file to the ftp server (server B), and then delete that file.
Here is what the company asked from me:
The software for file transfer we use in this section is free to all (filezilla) however if you don’t have the technical know there are alternate methods we can apply. The primary route for receiving orders is via our standard format and sent to the company’s FTP server. (FTP server details to be supplied by 3PL prior to integration)
By exception, a secondary route can be applied nevertheless the order file should be completed and sent to the following email address: operationalsupport@3p-logistics.co.uk
Is there another way we can play around it?
I have an e-commerce website, when a buyer buy a product it create an excel file for him in my local website and send that file to the ftp server (server B), and then delete that file.
Here is what the company asked from me:
The software for file transfer we use in this section is free to all (filezilla) however if you don’t have the technical know there are alternate methods we can apply. The primary route for receiving orders is via our standard format and sent to the company’s FTP server. (FTP server details to be supplied by 3PL prior to integration)
By exception, a secondary route can be applied nevertheless the order file should be completed and sent to the following email address: operationalsupport@3p-logistics.co.uk
Is there another way we can play around it?
Re: Uploading file into ftp server
Find the person responsible for configuring the FTP server and tell them to set it up to use the standard TCP ports: 21 for control packets and 20 for data packets. Otherwise, you might have to try the email option.
-
YoussefSiblini
- Forum Contributor
- Posts: 206
- Joined: Thu Jul 21, 2011 1:51 pm
Re: Uploading file into ftp server
Thank you very much for allllllllllllllllll your help, I really appreciate that, you made it clear for me now.
Thank you again and again ...
Thank you again and again ...
Re: Uploading file into ftp server
I am happy to serve.
I hope you get it straightened out.