How to upload FILE via FTP ?

Is there a Cocoa API to upload file to a web site ?
here) with your favorite command line tool (ftp, sftp, curl, etc.)
3. You can't use standard
NSFileManager methods once you have mounted the remote FTP file system using mount_ftp (man mount_ftp), because currently the mount is made read-only, but the method works for download. You can use mount_ftp from a pipe or NSTask:
mkdir /tmp/my_remote_ftp_node
mount_ftp my_login:my_password@ftp.my_domain /my_remote_ftp_node
# put your copy instruction here, example
# cp -r my_source /tmp/my_remote_ftp_node/my_destination
umount -f /tmp/my_remote_ftp_node
Or in C
mount("ftp", "/tmp/my_remote_ftp_node", 0, (void *)"my_login:my_password@ftp.my_domain");
4. Greg Hulands's has written a basic FTPConnection class
5. The "URL Acess Scripting" AppleScript extension allows upload and download of files, see
WebMasterMac and tidBits
6. You could pipe to
curl or launch a NSTask...
7. there is also the
wput utility, symetric to GNU wget
8. The
NSData method writeToURL:atomically: can be used with a ftp://user:password@host/path_to_file url.
9. Last but not least, CoreFoundation includes
CFFTP
The following methods are available from a Cocoa application to handle ftp communication:
1. You can link to libcurl (man libcurl) or other ftp client libraries
2. You can use expect (see our example





Authored by: Eric Brunstad on Tuesday, March 08 2005 @ 01:29 AM GMT
Though all of the techniques posted above do work to some extent, I have found a much easier and more reliable way to add FTP to Cocoa programs. This is to create a NSTask wrapping the Unix command FTP. It will allow you to execute any FTP commands, such as uploading and downloading files.
I have provided a sample application named
Workbench on my site, which demonstrates the use of NSTasks. It is a fully featured app which allows teachers to post homework on a server so students can see it. If you have any questions about NSTasks or FTP, feel free to email me at ericbrunstad@excite.com. I know how intimidating NSTasks can be!