i implemented a code using ASIFormDataRequest to upload a file to server
my code goes like this:
NSURL *url = [NSURL URLWithString:@"someurl"];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"medelix.db" ofType:nil];
NSData *myData = [NSData dataWithContentsOfFile:filePath];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:@"file" forKey:@"serverIP"];
[request setData:myData withFileName:@"Data.txt" andContentType:@"application/octet-stream" forKey:@"uploadedfile"];
// [request setProgressDelegate:self];
[request setDelegate:self];
[request setDidFinishSelector:@selector(postFinished:)];
[request setDidFailSelector:@selector(postFailed:)];
[request startAsynchronous];
NSData *newStringData = [request responseData];
NSString *x = [[[NSString alloc] initWithData:newStringData encoding:NSUTF8StringEncoding] autorelease];
NSLog(@"result text from server is %@", x);
my server side PHP is :
<?php
$target_path = '/Applications/XAMPP/xamppfiles/htdocs/myupload/';
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
else{
echo "There was an error uploading the file, please try again!";
}
?>
Bug I found while running :request responseData does not gave any thing
Now i wants to send a Block of data to server through ASIFormDataRequest,until the file contain is not finished (sending file contain chunk by chunk ).
can any body suggest me with a piece of code that how to send data chunk by chunk using ASIFormDataRequest?
Your Upload native code look som thing like this :
And the server side code will be :–
+