PHP data is streamed in a streaming way

Source: Internet
Author: User
Tags what header
PHP files are streamed in a streaming way
Scene:
The client gets the MP3 file on the server to play, but for some reason the client cannot write the file, that is, the operation cannot be downloaded.
The idea now is to read the MP3 buffer into memory with fopen-fread->echo on the PHP side, and the client receives the buffer in memory and plays the sound in memory.

Problem:
Now there is a 5143-byte Mp3 on the server, but the client only receives 5042. Test is that some characters are escaped, in the Internet to find a lot of methods, seems to be not good, PHP learned, what method can let him do not escape to get the correct file buffer.
file Stream Stream Mode Transfer

Share to:


------Solution--------------------
fopen using ' RB ' to open
------Solution--------------------
yge.me/ Xx.mp3/index.php

index.php
Header ("Location:http://yge.me/x.mp3");
The full URL address of the MP3.
X.mp3 for Real files
?>
------Solution--------------------
1, with Echo file_get_contents (' filename '); No other issues to consider
2, with ReadFile (' filename '); No other issues to consider
3, the client can write files, not the service side can control things
------Solution--------------------
I have a question, your PHP will not be sent to the header, right? What header?
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.