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

Similar Threads
thread Thread Starter Forum Replies Last Post
Video upload ozmanyyy iMac 2 Nov 15, 2013 01:01 PM
How do i upload pictures! napolean hill MacBook Pro 3 Nov 15, 2013 03:47 AM
Upload to iTunes 4God Digital Audio 2 Apr 5, 2013 06:49 PM
ASIFormDataRequest submission for ASP.net form merrickdrfc iPhone/iPad Programming 3 Jul 19, 2012 08:42 AM
What is the YouTube upload limit for iOS devices? Can I upload privately? HappyDude20 iOS 5 and earlier 1 Jun 8, 2012 04:13 PM

Forum Jump

All times are GMT -5. The time now is 09:57 AM.

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

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2015, MacRumors.com, LLC