在Win 7机器中使用unlink时出现问题。这是我在getFile.php中的代码
$file_name = 'C:\xampp\htdocs\fw\tmp\my_file.php';
$myfile = fopen($file_name , 'a');
unlink(''.$file_name );
每次执行代码时,都会收到错误消息
警告:取消链接(C:\ xampp \ htdocs \ fw \ tmp \ my_file.php)[function.unlink]:C:\ xampp \ htdocs \ fw \ libraries \ getFile.php中的权限被拒绝79
有人有解决方案吗?
之前感谢,
答案 0 :(得分:12)
您无法删除已打开的文件
$file_name = 'C:\xampp\htdocs\fw\tmp\my_file.php';
$myfile = fopen($file_name , 'a');
..
fclose($myfiles);
..
unlink(''.$file_name );
答案 1 :(得分:1)
$file_name = 'C:\xampp\htdocs\fw\tmp\my_file.php';
$myfile = fopen($file_name , 'a');
unlink(''.$file_name );
您无法使用此
删除文件首先你需要关闭那个文件
使用
fclose($myfiles);
并使用
$filename="myfile.php";
unlink("../../../../"$filename);
您无法使用c:\xamp....
或http:\\file\files.php
答案 2 :(得分:0)
我正在使用Windows 10和xampp,这适用于,
unlink(pathinfo(realpath($file_name), PATHINFO_DIRNAME).DIRECTORY_SEPARATOR . $file_name);