views:

165

answers:

2

Hello,

I was wondering the best way to upload file to a web server in cocoa. I cant seem to get my curl code to work even though it works when run from terminal.

curl code:

system(@"curl -T /file.txt http://webserevertouploadto.com")

Thanks for any help

+4  A: 

Try using NSTask instead of system() to execute curl. If you're looking for a native Cocoa solution for uploading files via FTP, take a look at ConnectionKit.

macatomy
Thanks for the Reply!
happyCoding25
Heres a site I found on NSTask http://cocoadevcentral.com/articles/000025.php
happyCoding25
+1  A: 

One negative of using curl is that it won't respect the user's proxy settings.

I prefer to use the NSURLConnection API.

Check this out: http://www.cocoadev.com/index.pl?HTTPFileUploadSample

Leibowitzn
Thanks for the reply but it seems like a lot of code just to upload a file when you can use curl in only a few lines.
happyCoding25
happyCoding: You missed the first paragraph of the answer. “curl… won't respect the user's proxy settings.” You can tell curl to use a proxy, but you'd still have to get the proxy settings to give to it, and then it's not “only a few lines” anymore.
Peter Hosey