您的位置:首页 > Web前端 > HTML

文件上传-html

2016-06-03 07:33 375 查看
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>文件上传</title>
</head>
<body>
<form action="./action.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="900000000" />
上传路径(填写上传路径的时候不能加双引号:例子:./ulike):<input type="text" name="filepath"><br>
上传文件大小:<input type="text" name="maxsize"><br>
shopimge:<input type="file" name="shopimg[]"><br>
shopimge:<input type="file" name="shopimg[]"><br>
shopimge:<input type="file" name="shopimg[]"><br>
<input type="submit" name="sub" value="添加商品">

</form>
</body>
</html>

action.php

<?php

require("./FileUploadsM.class.php");
/*filepath,allowtype,maxsize,israndname*/
$filepath=$_POST['filepath'];//填写上传路径的时候不能加双引号
$maxsize=$_POST['maxsize'];
$up=new FileUpload(array('israndname'=>false,'allowtype'=>array('html','txt','png','jpg','cpp','bmp'),'filepath'=>$filepath,'maxsize'=>$maxsize));
$up->uploadFile("shopimg");
echo "<pre>";
print_r($up);
print_r($_FILES);
echo "<pre>";
/* if($up->uploadFile($_FILES['shopimg'])){
echo "文件上传成功,上传后的文件名是:".$up->getNewFileName()."<br>";
}else{
echo "文件上传失败,失败的原因是:".$up->getErrorMsg().'<br>';
}*/
?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: