我已經多次檢查這段代碼,但仍然看不出有什么問題。這段代碼是[url]/sig/index.php 的內容。每次運行它時,我都會收到“抱歉,出現錯誤”。但是當我檢查我試圖復制的新舊文件的值時,它們很好。我在做傻事嗎?我在同一臺服務器上的其他頁面中使用了復制功能,所以我確定代碼一定有問題。這是一個簡單的頁面,用于復制同一目錄中的文件,覆蓋以前的文件。我知道源文件存在,因為我有一個始終有效的“源文件測試鏈接”。<?php$formval = $_POST["banners"] ;$newname = "banner-main.png" ;$dir = "/sig/" ;$img_to_copy = $dir . $formval . ".png" ;$newimg = $dir . $newname ;if (copy($img_to_copy, $newimg)) { echo ($formval . " is the new email signature image.") ; } else { echo "Sorry, there was an error."; } ;echo '<a href="' . $img_to_copy . '?var=' . rand(0,1000000) . '" target="_blank">Test link to source file</a>' ;?> <h1>Which banner is next?</h1><br> <form action="/sig/index.php" method="post"> <input type="radio" name="banners" value="banner-1">Banner 1 <br> <input type="radio" name="banners" value="banner-2">Banner 2 <br> <input type="radio" name="banners" value="banner-3">Banner 3 <br> <input type="radio" name="banners" value="banner-4">Banner 4 <br> <input type="submit" value="Submit"> </form>
1 回答

翻翻過去那場雪
TA貢獻2065條經驗 獲得超14個贊
你的問題很可能是$dir = "/sig/"
你在那里。
當查看文件(在 HTML 中)時,它使用sig/
來自您的域/項目的Web 服務器 DocumentRoot的文件夾。
復制時將使用文件系統根目錄sig/
中的文件夾(該文件不存在)。
復制文件時更改或使用完整的$dir = "/sig/"
文件系統$dir = "./sig/"
路徑。
- 1 回答
- 0 關注
- 104 瀏覽
添加回答
舉報
0/150
提交
取消