我尝试了这个:
$temp = tmpfile();
file_put_contents($temp,file_get_contents("$path/$filename"));
但我收到此错误:“警告:file_put_contents()期望参数1为字符串,”
如果我尝试:
echo file_get_contents("$path/$filename");
它返回以长字符串形式显示文件内容。我哪里错了?
tmpfile()
在读写(w +)模式下创建一个具有唯一名称的临时文件,并返回一个文件句柄,例如与fwrite一起使用。
$temp = tmpfile();
fwrite($temp, file_get_contents("$path/$filename"));
关闭文件时(例如,通过调用fclose()或tmpfile()返回的文件句柄没有剩余引用)或脚本结束时,将自动删除文件。看看php ref。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句