PHP通过file:// url读取文件

克拉斯·斯科纳梅克(Klaas Schoenmaker)

我正在尝试使用PHP将一些图像文件上传到服务器,发送到PHP的URL类似于

file:///用户/ [用户] /库/Application%20Support/iPhone%20Simulator/7.0/Applications/ [会话ID] /Upload%20test.app/file.txt

我使用以下代码读取文件的内容:

$url = "someurl";

$file = fopen($url, "rb");

$filename = $id;

$newfile = fopen($filename, "wb");

echo "File path: ".$url."<br/>";
echo "File contents: <br/>";
echo file_get_contents($url);

但是file_get_contents();什么也没返回,有什么提示吗?

杰伊·帕特尔(Jay Patel)

您不能采用read这种方式,但是您想在其中读取数据并local drive编写full pathrelative path获取文件内容,

demofile.txt

hello this is file first line.
this is another line.

index.php

<?php
    $url = "A:\wamp\www\demofile.txt";
    echo file_get_contents($url);
?>

结果

在此处输入图片说明

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章