簡體   English   中英

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頁面:

$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')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM