超简单的php文件上传程序
本文章提供一款简单的php文件上传程序,很简单就是利用了move_uploaded_file把文件上传到与你php 同一目录的下面.
PHP实例代码如下:
<!doctype html>
<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>
<?php
//文件上传
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;
}
?>永久链接:http://www.phprm.com/scxz/fs3158.html
转载随意!带上文章地址吧。