PHP无刷新上传面向过程写法iframe
生活随笔
收集整理的這篇文章主要介紹了
PHP无刷新上传面向过程写法iframe
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
代碼
https://github.com/7117/phpCollection/
https://www.jb51.net/article/75804.htm
說明
因為form表單提交會跳轉至action指定的文件,所以我們采用iframe進行接收form的上傳文件,
提交:提交form指定的iframe? 這個ifamr就在本頁面? ?然后進入到指定的php代碼
回復:php運行結果回復到iframe ,在iframe進行顯示
HTML
<!DOCTYPE html> <html> <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title></title> </head> <body><form enctype="multipart/form-data" method="post" target="upload" action="./upload.php" > 姓名:<input type="text" name="name" /><p>上傳:<input type="file" name="uploadfile" /><input type="submit" /> </form> <!-- display: none;設置隱藏不見 --><iframe name="upload" style="border:2px red solid;width:500px;height:500px"></iframe></body> </html>PHP
<?php header('content-type: text/html; charset=utf-8');$word=$_POST["name"]; echo $word; echo '<br>'; $bool=move_uploaded_file($_FILES['uploadfile']['tmp_name'],'./up.png'); echo "上傳成功";?
總結
以上是生活随笔為你收集整理的PHP无刷新上传面向过程写法iframe的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 一般当兵几年退伍
- 下一篇: PHP无刷新上传面向对象写法iframe