如何使用php从文件夹中的子文件夹中删除文件

如何使用php从文件夹中的子文件夹中删除文件,php,Php,我必须从数据库中删除一个文件,还必须使用php从服务器中存储为filefolder/newslettesubfolder/file1的文件夹中删除该文件。Iam使用以下代码,该文件正在从数据库中删除,但不是从文件夹中删除,…plz帮助,提前感谢 我的代码是 <?php $id = intval($_REQUEST['id']); include 'db/connection.php'; $sql1 = mysql_query("select * from newsletters wh

我必须从数据库中删除一个文件,还必须使用php从服务器中存储为filefolder/newslettesubfolder/file1的文件夹中删除该文件。Iam使用以下代码,该文件正在从数据库中删除,但不是从文件夹中删除,…plz帮助,提前感谢

我的代码是

<?php

$id = intval($_REQUEST['id']);

include 'db/connection.php';

$sql1 = mysql_query("select * from newsletters where id=$id");
$results = mysql_fetch_array($sql);

if ($results["file"] != "") {

    $image = $results["file"];

    unlink('../files/newsletter/' . $image);
}

$sql = "delete from newsletters where id=$id";

$result = @mysql_query($sql);

if ($result) {
    echo json_encode(array('success' => true));
} else {
    echo json_encode(array('msg' => 'Some errors occured.'));
}

?>

注意此路径。/files/newsletter/应提及正确的路径,如果您的服务器基于ubuntu,则更改对文件、新闻稿文件夹的权限。

y r u使用。。符号包含此代码的页面/文件的路径是什么?请阅读php manaul.FYI上的exec命令,mysql函数已被弃用。改用mysqli或PDO。Iam使用1和1服务器服务器服务器操作系统是linux还是windows?