Php Data is transmitted as a stream

Source: Internet
Author: User
Php files are transmitted as Streams & nbsp; scenario: & nbsp; the client obtains the mp3 files played on the server, however, the client cannot write files or download files for some reason. & Nbsp; the current idea is to transfer files in the form of streams in p php.
Scenario:
The client obtains the mp3 file on the server for playing, but the client cannot write the file or download the file for some reason.
The idea is to use fopen-> fread-> echo on the php end to read the mp3 buffer into the memory. the client receives the buffer and stores it in the memory, and then plays the sound in the memory.

Problem:
Now there is a 5143-byte Mp3 on the server, but the client only receives 5042. some characters have been escaped during the test. I have found many methods on the internet and it seems that I can't even use them. php has just learned how to prevent him from escaping to get the correct file buffer.
File Stream transmission and sharing :? Fread? -> E... 'data-pics = ''>
------ Solution --------------------
Use 'RB' to open fopen
------ Solution --------------------
Yge. me/xx133/index. php

Index. php
Header ("Location: http://yge.me/x.mp3 ");
// All URL addresses of MP3.
// X.mp3 is a real file
?>
------ Solution --------------------
1. use echo file_get_contents ('filename '). you do not need to consider other issues.
2. use readfile ('filename '). you do not need to consider other issues.
3. whether the client can write files is not managed by the server.
------ Solution --------------------
I have a question, isn't your php sending a header? 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.