dongtaoxue4674 2015-07-10 05:45
浏览 104
已采纳

使用Php发送文件内容(net :: ERR_CONTENT_LENGTH_MISMATCH)

I would like to know how can I send a mpeg file content to a client browser.

I have this code:

<?php
header("Content-Type: audio/mpeg");
header("Content-Length: ".filesize("13662f12.mp3"));
header("Cache-Control: no-cache");
readfile("13662f12.mp3");

On local it works fine. but on server the file stops reading after 10 seconds. I downloaded the song with ctrl+s and play it with a player without any problem.

I have this error: net::ERR_CONTENT_LENGTH_MISMATCH on Chrome.

I tried on Firefox too but nothing.

I would like to know why too!

  • 写回答

1条回答 默认 最新

  • duanbi3786 2015-07-10 09:03
    关注

    Your code is correct. The issue is related with server settings. Maybe there's a execution time limit set on the server. Disable it with set_time_limit(0); (if it's allowed).

    Also, try to figure out what causes the issue. Try to send smaller files and check if they are sent correctly. Inspect the headers that the server sends.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 u盘问题:盘符不显示 无媒体
  • ¥50 R语言读取nc按月均值转为tif
  • ¥30 智能车串级pid调参
  • ¥15 visual studio code翻译老是错误
  • ¥20 卫星测高数据的高程转换
  • ¥15 爬取招聘网站数据信息
  • ¥15 安装完tensorflow,import tensorflow as tf后报错,如何解决?
  • ¥15 ultralytics库导出onnx模型,模型失去预测能力
  • ¥15 linux下点对点协议连接2个USB串口的硬件流量控制问题
  • ¥15 SQL数据自动生成问题