for($i=0; $i<count($_POST['list']); $i++) {
echo $_POST['list'][$i];
if(is_file($_POST['list'][$i])) echo "ok"; else echo "false";
unlink($_POST['list'][$i]);
}我正在尝试删除我的服务器中的图像文件。
echo $_POST['list'][$i]输出../Profile/JPN012/test2.JPG(图像路由)。
但是is_file()和unlink()没有发挥作用。虽然我更改了所有目录和图像file(0777)的权限,但它不起作用。
(Linux操作系统环境)
有什么问题吗??
发布于 2014-02-16 04:26:53
我认为问题在于is_file和unlink中的文件路径参数。如果您可以在调用is_file或unlink之前将目录更改为文件所在的位置,则会更容易。之后,您只能使用像is_file这样的文件名(‘test2.png’)。
<?php
$old = getcwd(); // Save the current directory
chdir($path_to_file);
unlink($filename);
chdir($old); // Restore the old working directory
?>(资料来源:http://au1.php.net/chdir)
发布于 2014-02-16 04:27:28
检查服务器中的路径,最有可能是
$compositefilename = PATH_TO_YOUR_WEB_ROOT . "/composite/" . $compositeresult;https://stackoverflow.com/questions/21807190
复制相似问题