I have a small script that I am try to port to work for serving video data to the iPhone/Blackberry/PalmPre etc.
The code is ridiculously simple:
$type = "video/3gpp"; /* get mimetype from db */
$fileid = "0001"; /* File path from db */
header( "Content-Length: " . filesize( $fileId ) );
header( "Content-type: $type" );
readfile( $fileId );
It simply 开发者_如何学Cget's a file id based on arguments and uses readfile to send the file down to the requester.
However for some odd reason it only works once. If you try to access the page two times in a row on both the iPhone and BlackBerry it will work the first time. Then either any time after it will either time out or just stop responding to the request. This behavior is not the same on a non-mobile device, it works fine in Firefox/Safari/Chrome. I am fairly certain It has nothing to do with caching either on the non-mobile side.
Any Idea's why this might happen?
Looks like this might be caused my some strange behave with PHP not being able to detect when a browser closes a connection while PHP is sending data.
View the bug that has been open in PHP since 2004 http://bugs.php.net/bug.php?id=30301
精彩评论