开发者

Xcode iPhone SDK - Uploading a file

I want to upload a file to a website (In this case MediaFire)

Non-working code i got so far:

NSString *File2upload = @"Documents/data.xml";

NSURL *url = [NSURL URLWithString:@"http://username@hotmail.com:password@mediafire.com/data.xml"];
[File2upload writeToURL:url atomically:YES encoding:开发者_Go百科NSUTF8StringEncoding error: NULL];


Rather than ignore the error (by passing NULL as the error: argument), you should take a look at the NSError object returned by the call. The name of the NSString method you're calling (writeToURL:atomically:encoding:error:) may suggest you can use arbitrary schemes, but in fact only file://... urls will work.

If you want to upload a file to an ftp server, you'll need to use an ftp client library, such as those mentioned in this previous answer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜