M
M
mitaichik2015-06-04 15:39:35
PHP
mitaichik, 2015-06-04 15:39:35

How to give a file for android?

Hello. I'm trying to give the android a pdf file on the server side (php). The function is simple:

$pdfPath = '....';
    $filename = '...';
    header('Content-Type: application/pdf');
    header('Content-Disposition: inline; filename="' . $filename . '"');
                readfile($pdfPath);

The browser opens fine, but on the android side I get an error.
But on android I get the error org.apache.http.MalformedChunkCodingException: Chunked stream ended unexpectedly
The problem seems to be not on the server side (the browser opens perfectly), not on the android side (if you open pdf at its direct url (without php), it loads normally in android)
At the same time, it has rather strange behavior: it tries several times to request this url with pdf.
Added Content-Length - began to request once, but saves only the first 128Kb ... Tell me
what to do?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question