我已經(jīng)多次檢查這段代碼,但仍然看不出有什么問題。這段代碼是[url]/sig/index.php 的內(nèi)容。每次運(yùn)行它時,我都會收到“抱歉,出現(xiàn)錯誤”。但是當(dāng)我檢查我試圖復(fù)制的新舊文件的值時,它們很好。我在做傻事嗎?我在同一臺服務(wù)器上的其他頁面中使用了復(fù)制功能,所以我確定代碼一定有問題。這是一個簡單的頁面,用于復(fù)制同一目錄中的文件,覆蓋以前的文件。我知道源文件存在,因?yàn)槲矣幸粋€始終有效的“源文件測試鏈接”。<?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貢獻(xiàn)2065條經(jīng)驗(yàn) 獲得超14個贊
你的問題很可能是$dir = "/sig/"
你在那里。
當(dāng)查看文件(在 HTML 中)時,它使用sig/
來自您的域/項(xiàng)目的Web 服務(wù)器 DocumentRoot的文件夾。
復(fù)制時將使用文件系統(tǒng)根目錄sig/
中的文件夾(該文件不存在)。
復(fù)制文件時更改或使用完整的$dir = "/sig/"
文件系統(tǒng)$dir = "./sig/"
路徑。
- 1 回答
- 0 關(guān)注
- 115 瀏覽
添加回答
舉報
0/150
提交
取消