檢視 Ajax 的原始碼
←
Ajax
跳至導覽
跳至搜尋
由於以下原因,您無權編輯此頁面:
您請求的操作只有這個群組的使用者能使用:
使用者
您可以檢視並複製此頁面的原始碼。
==檔案上傳== ===前台程式=== <pre><!DOCTYPE html> <html> <head> <title> Ajax JavaScript File Upload Example </title> </head> <body> <!-- HTML5 Input Form Elements --> <input id="fileupload" type="file" name="formData" /> <button id="upload-button" onclick="uploadFile()"> Upload </button> <!-- Ajax JavaScript File Upload Logic --> <script> async function uploadFile() { let formData = new FormData(); formData.append("file", fileupload.files[0]); await fetch('./upload.php', { method: "POST", body: formData }); alert('The file has been uploaded successfully.'); } </script> </body> </html></pre> ===對應的後台程式 upload.php=== <pre><?php /* Get the name of the uploaded file */ $filename = $_FILES['file']['name']; /* Choose where to save the uploaded file */ $location = "./upload/".$filename; /* Save the uploaded file to the local filesystem */ if ( move_uploaded_file($_FILES['file']['tmp_name'], $location) ) { echo 'Success'; } else { echo 'Failure'; } ?></pre>
返回到「
Ajax
」。
切換側邊欄
導覽
首頁
近期變更
隨機頁面
MediaWiki說明
工具
連結至此的頁面
相關變更
特殊頁面
頁面資訊
六年制學程
導覽選單
個人工具
登入
命名空間
頁面
討論
變體
視圖
閱讀
檢視原始碼
檢視歷史
更多
搜尋