Actually i am downloading the file from my ios app using ASIHTTPRequest Library. I want to pass the international characters(it's a file name) via php header response while downloading the file. Basically am creating the new custom header called "filename-display" while construction the file download header response.
Here my PHP code:
<?php
$dir = 'c:\좋은 아침.pdf';
$filename_display = '좋은 아침.pdf';
if (file_exists($dir)) {
header("HTTP/1.1 200");
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($dir));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('filename-display:' . $filename_display);
header('Content-Length:' . filesize($dir));
ob_clean();
flush();
readfile($dir);
exit;
}
else {
header("HTTP/1.1 404 file not found");
echo 'file_not_exists';
exit(0);
}
?>
Client Code ASIHTTPRequest Library Delegate calls:
#pragma mark
#pragma ASIHTTPREQUEST delegate methods
-(void)requestStarted:(ASIHTTPRequest *)request{
NSLog(@"\n file download start");
}
-(void)updateUploadProgress:(ASIHTTPRequest*)request
{
[request updateUploadProgress];
}
- (void)requestFailed:(ASIHTTPRequest *)request {
//handle it
}
- (void)requestFinished:(ASIHTTPRequest *)request {
NSDictionary *responseHeaders = [request responseHeaders];
NSLog(@"\nresponse header dict = %@", responseHeaders);
NSLog(@"\nfile name: %@", [responseHeaders objectForKey:@"filename-display"]);
}
Output on my ios app:
file name: ?????????.pdf instead of shows the actual file name configured on php header side.
Let me know what encoding i can use on php side?. Also it's possible to pass the xml string via header response?.
Any help that might me appreciated.
-loganathan