Aleksander Azizi
Aleksander Azizi

Reputation: 9877

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://[email protected]:[email protected]/data.xml"];
[File2upload writeToURL:url atomically:YES encoding:NSUTF8StringEncoding error: NULL];

Upvotes: 2

Views: 2608

Answers (1)

odrm
odrm

Reputation: 5249

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.

Upvotes: 3

Related Questions