我希望用戶能夠通過點擊複選框並提交表單來刪除文件。
某處在標題:爲什麼這個取消鏈接功能不起作用?
foreach ($_POST ['files'] ['deleteFile'] as $value)
{
unlink ($value);
$fileError = '¡Éxito!';
}
身體某處:
<form enctype="multipart/form-data" method="post" name="files">
<!-- No action attribute was added as the form is processed in the same file -->
<?php
foreach (glob ('files/*.*') as $file)
{
echo $file . '<input name="deleteFile" type="checkbox" value="' . $file . '">';
}
?>
<input type="submit" value="Confirmar">
</form>
看起來你需要'unlink('files /'.$ value);' – Ohgodwhy 2014-09-22 21:41:19
@Ohgodwhy:不,'$ value'似乎有完整的路徑。 – 2014-09-22 22:01:54