Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread Display Modes
Old Jan 9, 2013, 10:52 PM   #1
macrumors 65816
Join Date: Sep 2006
no upload usign ASIFormDataRequest

I am working on a little app to upload files to my server and wow what a pain it is compared to downloading them. I have an NSOpenPanel that allows me to select a file. In this case I am just picking a .jpg file to test. My setDidFinishSelector gets called and said logged in, but when I check my server the file is not there. I changed the user/pass in the code I posted but it seems to log in fine. But it fails to upload a file? Can anyone see the problem off hand?

    NSOpenPanel *savePath = [NSOpenPanel openPanel];
    [savePath setCanChooseFiles:YES];
    [savePath setCanChooseDirectories:YES];
    NSInteger result = [savePath runModal];
    NSString *stringFromIndex;
    if (result == NSCancelButton) {
        [savePath orderOut:self];
    if ( result == NSOKButton) {

        NSString *tempString = [[NSString alloc] initWithString:[[savePath URL]absoluteString]];
        NSArray *cutString = [tempString componentsSeparatedByString:@"file://localhost"];
        stringFromIndex = [cutString objectAtIndex:1];
        NSData *dataToUpload = [[NSData alloc] initWithContentsOfFile:stringFromIndex];
        NSURL *url = [NSURL URLWithString:@"http://user:pass@website/uploads/"];
        request = [[ASIFormDataRequest alloc] initWithURL:url];

        [request addData:dataToUpload forKey:@"file"];
        [request setDelegate: self];
        [request setDidFailSelector: @selector(loginRequestFailed)];
        [request setDidFinishSelector: @selector(loginRequestFinished)];
        [request startAsynchronous];
    NSLog(@"Loged in");

I know more than yesterday.
larswik is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -5. The time now is 01:50 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013,, LLC