確定建立一個php webform需要其中一個條目是寫入的文件名。Php上傳表單userinput =文件名
我該如何做到這一點?
這裏是我的PHP代碼...
$filename = "output.txt"; #Must CHMOD to 666
$text = $_POST['bin'];
$text2 = $_POST['pcn'];
$text3 = $_POST['gnum'];
$text4 = $_POST['memid'];
$text5 = $_POST['urlen'];
$text6 = $_POST['urles'];
$text7 = $_POST['tlogo'];
# Form must use POST. if it uses GET, use the line below:
#$text = $_GET['theformfieldname']; #POST is the preferred method
$fp = fopen ($filename, "w"); # w = write to the file only, create file if it does not exist, discard existing contents
if ($fp) {
fwrite ($fp, "$text\r\n");
fwrite ($fp, "$text2\r\n");
fwrite ($fp, "$text3\r\n");
fwrite ($fp, "$text4\r\n");
fwrite ($fp, "$text5\r\n");
fwrite ($fp, "$text6\r\n");
fwrite ($fp, "$text7\r\n");
fclose ($fp);
header("Location: logo.html");
}
else {
echo ("There was an error please submit your request again");
}
?>
確定需要$文件名= 「output.txt的」; 來自輸入$ text3 = $ _POST ['gnum']; 。
沿的線的東西:
$文件名= $ _POST [ 'gnum'] TXT; 但是這不會工作..
在此先感謝, 喬
Psst your code is broken。 :) – 2011-03-25 20:41:30
固定;)我確實想念'。'在'.txt'中,我做到了! – Nanne 2011-03-25 20:45:57
警告:fopen(rxc45632.txt)[function.fopen]:未能打開流:第15行的/var/www/test/form/welcome.php中的權限被拒絕 有錯誤請重新提交您的請求 – jmituzas 2011-03-25 20:47:56