Question

We are setting up a drop-ship agreement with a vendor to where we don't have to stock their products we just sell them and they ship them out. To inform them of an order they want us to FTP upload a tab delimited .txt file with the order info to their site. We want to automate this. So given the user/pass for the ftp is there a way to create a TSV.txt file and ftp upload it to their site with PHP?

Thanks!

Was it helpful?

Solution

PHP FTP Example

I'm not familiar with your order info of course, but you could create an array of the order information and use fputcsv to create the tab delimited file.

Do you need specifics on making the file from $_POST information as well? Or just general function calls to implement the solution?

Edit: Also, is it possible to find another solution then FTP'ing the information? Say, an HTTPS connection or something to their server? If you are sending any recipient information(address, zip, credit card) this could be a security problem.

OTHER TIPS

file_put_contents() in PHP5 or a combination of fopen()/fwrite()/fclose() in PHP4 should do the job. Anyway, you should supply the user and pass inside the FTP URL, like this:

ftp://user:password@example.com/pub/file.txt

If the above don't work, ftp_* functions should solve your problem. Anyway, pay attention to the PHP version they're available in. Some function only work in PHP5 and greater.

This is the page detailing the FTP stream wrapper in PHP.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top