亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 PHP 上傳多個文件并在 CSS 中存儲表單

使用 PHP 上傳多個文件并在 CSS 中存儲表單

喵喵時光機 2023-09-18 10:52:44
我有一個收集學生信息的表格,其簡單版本在這里:<form method="post" name="submit" action="submit" autocomplete="off"> <br><input type="name" id="forename" name="forename" placeholder="Forename" required> <br><input type="name" id="middlename" name="middlename" placeholder="Middle Name/s" required> <br><input type="name" id="surname" name="surname" placeholder="Surname" required> <br><input type="tel" id="mobile" name="mobile" placeholder="Mobile Number (+44)" required> <br><input type="email" id="email" name="email" placeholder="Email" required> <br><input type="message" id="course" name="course" placeholder="Course You're Studying" required> <br><input type="message" id="code" name="code" placeholder="Course Code" required> <br><input type="message" id="campus" name="campus" placeholder="Campus" required> <br><input type="message" id="message" name="message" placeholder="Comments"> <br><br><input type="file" title="Attach your ID" id="studentidentification" name="studentidentification" required> <br><input type="file" title="Attach personal ID" id="personalidentification" name="personaldentification" required> <br><br><input type="submit" name="submit" id="submit" value="Submit" required="">然后將該表格發送至submit.php例如。(該頁面有一個隨機 URL,然后將用戶發送到一個新頁面)接下來的 PHP 獲取所有用戶輸入并將其寫入 CSV,其中包括學生的文件名和個人身份信息以供交叉引用。PHP 還應該上傳文件夾內文件夾中的每個文件responses。所以csv,student和personal.由于某種原因,輸出了未知錯誤,我覺得這與兩個文件上傳到同一個文件中這一事實有關。兩個 ID 必須單獨填寫并在同一表格內。我希望我能得到報酬來解決這個問題,但我不知道從這里該去哪里,因為即使 CSV 也不會寫入,而這是基于有效的代碼。當目錄實際存在時,error_log已生成的Apache會拋出Undefined index大多數錯誤。failed to open stream: No such file or directory還有fwrite() expects parameter 1 to be resource, boolean given和fclose() expects parameter 1 to be resource, boolean。詢問是最后的手段,因為理論上這應該有效,如果由于某種原因這是一個明顯的錯誤,那么很抱歉。任何幫助將不勝感激。謝謝 :)
查看完整描述

1 回答

?
qq_花開花謝_0

TA貢獻1835條經驗 獲得超7個贊

有2個問題:

  1. 您需要在 URL 開頭 使用./代替,以便您的 URL 是相對的并且不會引用您網站的基礎。這將修復該錯誤。/failed to open stream: No such file or directory

  2. 如果您想發送文件,您需要enctype="multipart/form-data"在表單中添加:

    <form method="post" name="submit" action="submit" autocomplete="off" enctype="multipart/form-data">
        ...
        </form>

    這將修復該Undefined index: studentidentification in /home/hosting/domains/example.com/public_html/onboarding/forms/collectid/submit.php錯誤。

另外,請確保您已在php.inifile_uploads (PHP 配置)文件中進行設置。on


查看完整回答
反對 回復 2023-09-18
  • 1 回答
  • 0 關注
  • 96 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號