PHP文件上传【前后台编码】
生活随笔
收集整理的這篇文章主要介紹了
PHP文件上传【前后台编码】
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
目錄
PHP文件上傳前臺編碼:
PHP文件上傳后臺編碼:
PHP文件上傳前臺編碼:
<!DOCTYPE html> <html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title> </head><body><form action="index.php" enctype="multipart/form-data" method="post"><p><input type="file" name="file" required></p><p><input type="submit" value="上傳文件"></p></form> </body></html>PHP文件上傳后臺編碼:
<?php $file=$_FILES["file"]; #隨機文件名+文件的后綴名 $newFileName=uniqid().".".pathinfo($file['name'], PATHINFO_EXTENSION); #move_uploaded_file(存儲的緩存文件,存儲路徑/文件名稱) $result=move_uploaded_file($file['tmp_name'],$newFileName); if($result){echo "上傳成功";}else{echo"上傳失敗";} ?>測試:
?
?
測試成功。?
總結
以上是生活随笔為你收集整理的PHP文件上传【前后台编码】的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PHP酒店管理demo案例(数组遍历)
- 下一篇: 【PHP7.2+】win10安装lara