PHP 删除文件到文件夹
PHP Delete a file into a folder
我正在尝试根据用户的操作将特定文件名删除到文件夹中,但我收到此警告:
警告:unlink():http 不允许在
中取消链接
这是包含导航到 deleteRecord.php
按钮的代码
> <script> //btn delete
> $(".btn_delete").click(function(){
> var id = $(this).closest('tr').children('td:first').text();
> //alert(id);
> var x;
if (confirm("Are you sure you want delete this record?") == true) {
> //alert ("You pressed OK!");
>
> location.href='deleteRecord.php?filename='+filename;
> } else {
> //alert ("You pressed Cancel!");
> return false; }
> });
> </script>
这项工作非常好,我把它显示到哪里来的变量 id
现在这是 php 页面,return 警告:
$filename = $_GET['filename']; //get the filename like "yo.jpg"
$path = "http://www.here I have the exact address to the folder/";
unlink($path . '/' . $filename);
这是我再放一遍的结果!
******警告:unlink():http 不允许在 ******
中取消链接
有什么建议吗?有什么建议吗?请原谅我的英语,我正在学习!
您需要将 服务器的 文件路径作为参数传递给 unlink()
而不是 URL,例如:
unlink('/var/www/mywebsite.com/images/myimage.jpg')
我正在尝试根据用户的操作将特定文件名删除到文件夹中,但我收到此警告:
警告:unlink():http 不允许在
中取消链接这是包含导航到 deleteRecord.php
按钮的代码> <script> //btn delete
> $(".btn_delete").click(function(){
> var id = $(this).closest('tr').children('td:first').text();
> //alert(id);
> var x;
if (confirm("Are you sure you want delete this record?") == true) {
> //alert ("You pressed OK!");
>
> location.href='deleteRecord.php?filename='+filename;
> } else {
> //alert ("You pressed Cancel!");
> return false; }
> });
> </script>
这项工作非常好,我把它显示到哪里来的变量 id
现在这是 php 页面,return 警告:
$filename = $_GET['filename']; //get the filename like "yo.jpg"
$path = "http://www.here I have the exact address to the folder/";
unlink($path . '/' . $filename);
这是我再放一遍的结果!
******警告:unlink():http 不允许在 ******
中取消链接有什么建议吗?有什么建议吗?请原谅我的英语,我正在学习!
您需要将 服务器的 文件路径作为参数传递给 unlink()
而不是 URL,例如:
unlink('/var/www/mywebsite.com/images/myimage.jpg')