加入收藏 | 设为首页 | 会员中心 | 我要投稿 银川站长网 (https://www.0951zz.com/)- 云通信、基础存储、云上网络、机器学习、视觉智能!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

非常简单的php文件上传程序

发布时间:2023-06-07 12:58:22 所属栏目:PHP教程 来源:
导读:本文章提供一款简单的php文件上传程序,很简单就是利用了move_uploaded_file把文件上传到与你php 同一目录的下面.PHP实例代码如下:<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.o

本文章提供一款简单的php文件上传程序,很简单就是利用了move_uploaded_file把文件上传到与你php 同一目录的下面.

PHP实例代码如下:

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml"> 

<head> 

<meta http-equiv="content-type" content="text/html; charset=gb2312" /> 

<title>超简单的php文件上传程序</title> 

</head> 

<body> 

<form id="form1" name="form1" enctype="multipart/form-data" method="post" action=""> 

  <label for="filefield"></label> 

  <input type="file" name="name" id="filefield" /> 

  <input type="submit" name="button" id="button" value="开始上传文件" /> 

</form> 

</body> 

</html> 

<? 

//文件上传 

 代码如下 复制代码  

if($_files ) 

 upfiles($_files,'./'); 

function upfiles($files,$path){ 

 global $nowtimestamp; 

 $exname=strtolower(substr($files['name'],(strrpos($files['name'],'.')+1))); 

 $i=1; 

   if (!move_uploaded_file($files['tmp_name'], $path.$nowtimestamp.".".$exname)) {  

  showmessage("上传文件失败,请稍后重试!","?job=add",true); 

 } 

 return  $path.$nowtimestamp.".".$exname; 

?> 

(编辑:银川站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!