PHP按文件读取文件:// url

时间:2014-03-22 18:13:35

标签: php url upload

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

  

文件:///用户/ [用户] /Library/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();没有任何提示,任何提示?

1 个答案:

答案 0 :(得分:0)

你不能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);
?>

结果

enter image description here