我正在尝试使用以下代码查找WAV文件持续时间。
if ( !file_exists($location_wmv.$name_wmv) ) {
echo "<BR> File Does not Exist<BR>";
} else {
echo "<BR> File Exist<BR>";
}
$file = $location_wmv.$name_wmv;
$fp = fopen($file, ‘r’);
$size_in_bytes = filesize($file);
fseek($fp, 20);
$rawheader = fread($fp, 16);
$header = unpack(‘vtype/vchannels/Vsamplerate/Vbytespersec/valignment/vbits’,
$rawheader);
$sec = ceil($size_in_bytes/$header['bytespersec']);
$duration_wmv = $sec;
echo "<BR> Raw Suration.". $duration_wmv . "<BR>";
$duration_wmv = gmdate("H:i:s", $demo_song_duration_sec);
echo "<BR>WAV Duration".$duration_wmv;
这里file_exists函数表示文件存在。但是fopen上写的是failed to open stream: Undefined error: 0
该文件实际上存在于文件夹中。但是我仍然得到这个错误
This:
$fp = fopen($file, ‘r’);
看起来可疑的。这些是反引号吗?也许尝试:
$fp = fopen($file, 'r');
(简单的引用)