0

I am working on an upload code which will upload the file to the server, which is successfully working

now what I need as fallows:

started with an example-->suppose I have a file named file.txt, whose size is 30MB, when I read the contents of the file it will give me all the 30MB it contains. In the sendSynchronousRequest method I want to give request upto 10mb of data and aging calling the same thing unless it reaches at the last point of file. (in brief I want to use a loop to send the request part by part to the server

to solve the purpose i read form http://allseeing-i.com/ASIHTTPRequest/How-to-use and Included the ASIHTTPRequest in to my project after inclusion i want to do the same , that will accept a block of data (even via a POST) then append that block of data to a file. It seems to me that you need some kind of client side app that will take a file and break it up into chunks, then send it to your web service one chunk at a time.

My problems: -how to sent a Post Request from ASIHTTPRequest with a chunk of data? -do i need to change the PHP ?

Can any one post a piece of code for both php and ASIHTTPRequest so that i can take a reference from their.

Thank you guys for your continuos support .

Sagar Mohanty
  • 227
  • 1
  • 3
  • 12

3 Answers3

1
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:@"Ben" forKey:@"first_name"];
[request setPostValue:@"Copsey" forKey:@"last_name"];
[request setFile:@"/Users/ben/Desktop/ben.jpg" forKey:@"photo"];

From ASIHTTPRequest documentation

Alex Terente
  • 12,006
  • 5
  • 51
  • 71
1

You can refer to the following link available on the stack overflow:

NSURLConnection to upload file asynchonrously?

Community
  • 1
  • 1
Akhilesh Sharma
  • 1,580
  • 1
  • 17
  • 29
1

If you use a form in the website, it would be easier to use ASIFormDataRequest instead of the standard ASIHTTPRequest. The specific details are here: Using ASIFormDataRequest

Essentially, you just create the form fields in the website and reference them when you create the request. If you have any text fields in your form you use the

[request setPostValue:@"Your value" forKey:@"form key"];

The file should be sent through the path using

[request setFile:@"filepath to needed file" forKey:@"form key"];

If you want you can also send it asynchronously and use the delegate methods for tracking the progress of the upload.

I hope this helps.

Andres Bucci
  • 947
  • 1
  • 9
  • 37
  • Thank you so much... just one help i.e can you post a sample PHP code .for ASIFormDataRequest – Sagar Mohanty May 23 '12 at 09:47
  • I forgot to mention also check the parameter [request shouldUseRFC2616RedirectBehaviour] because if you set it to NO it would cause your request to be changed to a GET when you get redirected. I had a lot of problems with that. – Andres Bucci May 23 '12 at 09:50
  • I found this code. http://phpeasystep.com/phptu/1.html I don't know PHP but it even made sense to me – Andres Bucci May 23 '12 at 09:53