程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> PHP 文件上傳的綜合實例

PHP 文件上傳的綜合實例

編輯:關於PHP編程

1、upload.php

<!DOCTYPE HTML  "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Add文件上傳_www.jbxue.com</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> 
</head> 
<body>
<!--文件上傳要注意:1、要有enctyp,2、method="post"-->
<form enctype="multipart/form-data" action="uploadProcess.php" method="post" >
<table>
<tr><td>請填寫用戶名</td><td><input type="text" name="username"></td></tr>
<tr><td>請簡單介紹文件</td><td><textarea rows="7" cols="50" name="fileintro" 2、uploadProcess.php

<?
=['username'=['fileintro' 

=['myfile']['size'(>2*1024*1024 "<script type='text/javascript'>window.alert('文件不能大於2M')</script>"
=['myfile']['type'(!="image/jpeg" && !="image/pjpeg" "文件類型只能是 jpg 格式"
((['myfile']['tmp_name'
=['myfile']['tmp_name'
=['DOCUMENT_ROOT']."/file/up/".(!( (
=['myfile']['name'=."/".().(1,1000).(,(,"."
((,("utf-8","gb2312","" ['myfile']['name']."上傳成功" "上傳失敗" "上傳失敗"?>

<?
 ; 
 ; 
   ->upload_name=['myfile']['name'->upload_tmp_path=['myfile']['tmp_name'->file_size=['myfile']['size'->file_type=['myfile']['type'->allow_file_type = ('jpeg','jpg','png','gif','bmp','doc','zip','rar','txt','wps','xlsx','ppt'->file_save_path=['DOCUMENT_ROOT']."/file/up/"  upload_file(
(->file_size>2*1024*1024 "<script type='text/javascript'>window.alert('文件不能大於2M')</script>" 
=->getFileExt(->(!(,-> "上傳文件類型格式錯誤"
((->
=->file_save_path.(!( (
=."/".().(1,1000).(->upload_name,(->upload_name,"."
((->upload_tmp_path,("utf-8","gb2312","" ->upload_name."上傳成功" "上傳失敗" "上傳失敗"
  getFileExt(=( ["extension"?>

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved