Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In the server it is uploading but the pdf is not opening it says the attachment has some error [closed]

I generated the pdf in my iphone app, now i want to send that pdf to server. for that i am converting to NSData and i am sending.

I searched in google and i find solution by using "POST" but it is working for images.

In the server it is uploading but the pdf is not opening it says the attachment has some error

In the following code i did this:

NSData *pdfdata = [[NSData alloc] initWithData:[self.pdfFilePath dataUsingEncoding:NSASCIIStringEncoding]];
ASIFormDataRequest *request=[ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",MainUrl,@"updatefile.php"]]];
[request setDelegate:self];
        [request setPostValue:appDelegate.userId forKey:@"userid"];
         [request addData:pdfdata forKey:@"file"];
[request startSynchronous];

//self.pdfFilePath = /var/folders/a0/a01nF1oGGkebQxw7H0YsBU+++TI/-Tmp-/MyAccount.pdf;

Please guide me,

Thanks in advance.

like image 294
Babul Avatar asked Nov 13 '22 23:11

Babul


1 Answers

Instead of this

[request addData:pdfdata forKey:@"file"];

use the below code

[request setFile:self.pdfFilePath forKey:@"file"];
like image 133
Babul Avatar answered Nov 15 '22 11:11

Babul