我开发了一个插件,可以通过媒体将文件上传到上传文件夹。如果文件不符合x条件,则会处理该文件。该过程将中止,文件将被删除。
以这种方式调用unlink时,删除是有效的
if ($counter === 0) {
printMessage(\'No need to process\');
if (unlink($file)) {
printMessage(\'File removed\');
}
return;
}
在这里$file
是对wp_handle_upload
$upload[\'file\']
我的情况是,在验证文件确实已从文件系统中删除后,媒体库中会有一个对它的引用。
谢谢你的评论