我有这样一段代码在PHP中:file_exists无法与本地主机URL工作
if (file_exists($_POST['current_folder'])) {
//do something
}
但file_exists
始终返回false。传递给该函数的值是:
echo $_POST['current_folder']); //This prints: http://localhost/wordpress/wp-content/music
我也尝试了localhost上的不同文件夹。该函数总是返回false。我也试过is_dir()
。但即使这个函数返回false与上面的URL。
堆栈溢出有很多相关的问题。但大多数人认为file_exists
只适用于相对网址。但从this link很明显,http://
URL也支持file_exists
函数。
我错过了什么?
使用本地文件路径,而不是hte web路径 – 2015-03-08 20:18:58