【发布时间】:2018-07-25 17:19:46
【问题描述】:
我正在尝试将一组 MP3 文件下载到 ZIP 文件夹。所有 MP3 都托管在 S3 上。我的程序运行良好,除非 URL 包含这样的长破折号:https://s3.amazonaws.com/publicverses/2Corinthians11verse24–33_user400_56.mp3。
注意24 和33 之间的长破折号。此文件和其他类似文件显示在 ZIP 中为空(即 0kb)。我该如何解决这个问题?
foreach ($files as $file) {
$download_file = file_get_contents($file);
$zip->addFromString(basename($file), $download_file);
}
【问题讨论】:
-
urlencode可能吗? -
–是一个非 ASCII 字符,这可能会导致问题。试试urlencode() -
我应该把 urlencode() 函数放在哪里?
-
@jumpingmaniac
file_get_contents(urlencode($file))。我不太确定,但试试这个。 -
我就是这么想的。我试过了,但现在我所有的文件都是 0kb。
标签: php