Header menu

_________________________________________________________________________________

Friday 2 May 2014

PHP force file download method not working on android mobile when file path is passed from database


 

PHP force file download method not working on android mobile when file path is passed from database

When you use are using force download method of php to download some music/video on any android device ( I specifically performed for this ) . Then you might face two types of problems.

1.  You will get html page instead of media file.

2.  When you are passing file path from database, your file is not downloaded completely. It will show download complete after downloading some byte. In straight incomplete file is downloaded .

Below is the code that will work for solving these two problem. The points to remember are 

(a) Do not call download method from the loop where you are checking post or get request . Call download method out of GET/POST condition check loop. It is solve first problem of html pages download.

(b) Pass only file name from the database . Keep the file path static . I know this will make code hard coded but if you pass path from database then '/'  in path will create problem. And you will not be able to download file properly.



                                                I hope this will work for you too ..  :)

No comments:

Post a Comment