无法使用 fopen() 打开本地文件
你好。我正在尝试从 xlink 创建的 xml 打开本地文件,我已经解析了 $resourceRef 变量中的文件路径,它看起来像 file:/./birds/birds.txt
不带引号。请有人告诉我为什么我打不开它。这是我的代码
$fh = fopen($resourceRef, 'r');
$theData = fread($fh, filesize($resourceRef));
fclose($fh);
echo $theData;
,我收到此错误
警告:fopen(file:/./birds/feathers.txt) [function.fopen]: 无法打开流:第 31 行 C:\xampp\htdocs\test.php 中的参数无效
请有人指导我。
HI. i am trying to open a local file from xml created by xlink i have parsed the file path in $resourceRef variable and it looks like that file:/./birds/birds.txt
without the quotes. Please someone tell me why i cant open it. here is my code
$fh = fopen($resourceRef, 'r');
$theData = fread($fh, filesize($resourceRef));
fclose($fh);
echo $theData;
i get this error
Warning: fopen(file:/./birds/feathers.txt) [function.fopen]: failed to open stream: Invalid argument in C:\xampp\htdocs\test.php on line 31
Please someone guide me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的 URI 看起来不正确,它应该是
file://birds/birds.txt
或只是birds/birds.txt
。Your URI doesn't look correct, it should be either
file://birds/birds.txt
or justbirds/birds.txt
.参数应该是给定平台的合适路径(对于寡妇 "C:\\dir(...)" ),或正确的 URI ( file:// (...) )
Argument should be suitable path for a given platform (For widows "C:\\dir(...)" ), or correct URI ( file:// (...) )