如何在php中使用file_get_contents函数来读取特定文件夹中的文件内容?

时间:2014-02-03 11:30:18

标签: php

例如,我在/ upload文件夹中有一个图像文件。如何在php中使用file_get_contents函数来获取/ upload文件夹(特定目录)中的文件信息。我需要包含哪些参数?

2 个答案:

答案 0 :(得分:0)

这完全取决于当前文件所在的文件夹。

如果您使用其他文件夹中的file_get_contents:file_get_contents(../upload/filename)

如果您使用上传文件夹中的文件中的file_get_contents:file_get_contents('filename')

如果您使用上传文件夹子文件夹中的文件中的file_get_contents:file_get_contents('../filename')

答案 1 :(得分:0)

file_get_contents - >将整个文件读入字符串

getimagesize - >从图像中获取信息。

对于图像,您可以使用GD库,exif或imagemagick库,这些在几乎所有PHP安装中都很常见。