Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7703079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:22:37+00:00 2026-05-31T23:22:37+00:00

I want to upload data, images, txt files, pdf documents , etc. Im using

  • 0

I want to upload data, images, txt files, pdf documents , etc.
Im using MKNetworkKit to connect cleanly. With examples of this framework i try do it.
I add to my proyect a class extends of MKNetworkEngine with a method for upload from file:

#import "MKNetworkOperation.h"
#import "MKNetworkEngine.h"

@interface Uploader : MKNetworkEngine
-(MKNetworkOperation*) uploadFromFile:(NSString*) file 
                              onError:(MKNKErrorBlock) errorBlock; 
@end



#import "Uploader.h"

@implementation Uploader


-(MKNetworkOperation*) uploadFromFile:(NSString*) file 
                              onError:(MKNKErrorBlock) errorBlock 
{

    MKNetworkOperation *op = [self operationWithPath:@"IP:PORT/PROYECT/" 
                                              params:nil
                                          httpMethod:@"POST"];

    [op addFile:file forKey:@"upload"];
    [op setFreezable:YES];

    [op onCompletion:^(MKNetworkOperation* completedOperation) 
     {
         NSString *xmlString = [completedOperation responseString];
         NSUInteger start = [xmlString rangeOfString:@"<mediaurl>"].location;
          if(start == NSNotFound) 
          {
          NSLog(@"%@", xmlString);
          errorBlock(nil);
          return;
          }
          xmlString = [xmlString substringFromIndex:start + @"<mediaurl>".length];
          NSUInteger end = [xmlString rangeOfString:@"</mediaurl>"].location;
          xmlString = [xmlString substringToIndex:end];
     }
             onError:^(NSError* error) 
     {
         errorBlock(error);
     }];

    [self enqueueOperation:op];
    return op;

}
@end

I have added i my interface a button for upload file, and in my controller i,ve created a method with this content:

-(IBAction)uploadImageTapped:(id)sender 
{

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);

    NSString *cachesDirectory = [paths objectAtIndex:0];
    NSString *uploadPath = [NSString stringWithFormat:@"%@/Imagen.jpg",cachesDirectory];
    //NSLog(@"%@",uploadPath);

    self.uploadOperation = [ApplicationDelegate.sampleUploader uploadFromFile:uploadPath  onError:^(NSError* error) 
                            {
                                [UIAlertView showWithError:error];
                            }];
  }

Finally I,ve added a Uploader object in my delegate of app:

@property (strong, nonatomic) Uploader *sampleUploader;

and

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
    UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
    splitViewController.delegate = (id)navigationController.topViewController;

    //Uploader
    self.sampleUploader = [[Uploader alloc] initWithHostName:@"http://IP:PORT"
                                          customHeaderFields:nil];

    return YES;
}

My problem is that i want to can upload files, my localhost is not reachable and i dont know why….

Any ideas???

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T23:22:38+00:00Added an answer on May 31, 2026 at 11:22 pm

    [I’ve stumbled across your question whilst looking for some help myself with MKNetworkingKit.]

    Quickly reading through you code, I wonder if you should remove the ‘http://’ from your initWithHostName. I’m sure the kit add ‘http://’ somewhere within its own init.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to upload files directly to IIS7 (in this case I am using
i am using this code to upload files(images to a folder) <form action='' method='POST'
I want to upload and store video files to my server using PHP. Could
Using images with Core Data isn't a problem. There are a lot of examples
With this simple example <form action= method=post enctype=multipart/form-data> Upload images: <input type=file name=images[] multiple=multiple>
I'm using paperclip to allow user to upload images and I want to convert
i want to upload two files. here is the script <? ini_set('memory_limit', 400M); ini_set('file_uploads',
I want to upload some files of size 35MB on to the blob container.
I want to upload two images to the server with following code can any
I want my site to have a feature for users to upload images, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.