Coding For Online Success

FTP’ing files from CJ’s FTP server to your host


I had a few people email me about my Parsing XML CJ Product Feeds article regarding how to FTP the file to your server. You can use various FTP function depending on how your PHP is configured. I used wget to grab the files. It was easier to gather all of my feeds. To do this, you’ll need to use PHP’s exec() function to execute the wget program on the server (assuming you have access and permissions to use wget via script).

span class=”st0″>"wget -P/path/to/your/site/cj/files*.*"

This will log into the FTP server using the username:password values being passed. Please substitute this with your actual username and password. All files be sent to the path you specified with the -P argument. Please update this with a valid path on your system. If you don’t know what your directory structure is on CJ’s FTP server, you may need to contact CJ support or log in with a simple FTP client to see what your path is. My example is using ‘111111’ is just a example.

Once you have the files downloaded, they may be like mine and are zipped or gzipped. You could use exec() again to unzip it or install a PHP extension to unzip this (dev-php5/pecl-zip). If you need example of this, I can try to help. My server is customized by me, so I’m using the pecl-zip extension for PHP.


Leave a Reply

Required fields are marked *.

CommentLuv badge

This site uses Akismet to reduce spam. Learn how your comment data is processed.