我试图从网络文件夹和脚本中删除不相关的文件。
以下是代码:
<?php
if(isset($_REQUEST['delete_file'])){
if(isset($_GET['file_id'])){
$file_id = mysql_real_escape_string(strip_tags($_GET['file_id']));
$file_info_query = @mysql_query("select * from video where id='$file_id'");
$file_info_row = @mysql_fetch_assoc($file_info_query);
$filename = $file_info_row['filename'];
$path = $_SERVER['DOCUMENT_ROOT'].'/test2/video/';
$file_path = $path;
$file_path .= $filename;
if(unlink($file_path))
{
echo "<p>File deleted successfully.</p> ";
}
else
{
echo "<p>Unable to delete file. Try again shortly.</p> ";
}
}
}
?>
很高兴让这个工作......谢谢!
答案 0 :(得分:1)
取消链接功能需要文件的完整服务器路径。请将$ path值更改为此值:
$path = $_SERVER['DOCUMENT_ROOT'].'/test2/video/';