-2

我试图从 web 文件夹中删除不相关的文件,并且脚本无法正常工作。

这是代码:

<?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> ";
            }       

        }

    }



    ?>

将不胜感激让这个工作......谢谢!

4

1 回答 1

1

取消链接功能需要文件的完整服务器路径。请将您的 $path 值更改为此:

$path = $_SERVER['DOCUMENT_ROOT'].'/test2/video/';
于 2013-02-04T12:09:30.017 回答