php文件上传示例。。。
时间:2007-02-18
来源:PHP爱好者
在手机上看
手机扫描阅读
CODE:
[复制到剪切板]
<?php
/*
抛个砖,具体要做成什么样自己做。
*/
if(isset($_FILES['userfile']['tmp_name'])){
$userfile = $_FILES['userfile']['tmp_name']; //保存在系统的临时位置
$userfile_name = $_FILES['userfile']['name'];//文件名
$userfile_size = $_FILES['userfile']['size'];//文件大小,字节
$userfile_type = $_FILES['userfile']['type'];//文件类型
if(!is_dir("image")) mkdir ("image", 0700);
$upfile = "image/".$userfile_name;//保存位置
print_r($_FILES);
//move_uploaded_file($userfile,$upfile);//方法1
if(!copy($userfile,$upfile))//方法2
{
echo "上传失败";
exit();
}
echo "上传成功";
echo "<a href="#" onClick="window.history.back();">再上传一张</a>";
}
else{
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data" name="form1">
<input name="MAX_FILE_SIZE" type="hidden" id="MAX_FILE_SIZE" value="1000">
<input name="userfile" type="file" id="userfile">
<input type="submit" name="Submit" value="上传">
</form>
</body>
</html>
<?php }?> php爱好者站 http://www.phpfans.net php基础|php进阶|php模板.
/*
抛个砖,具体要做成什么样自己做。
*/
if(isset($_FILES['userfile']['tmp_name'])){
$userfile = $_FILES['userfile']['tmp_name']; //保存在系统的临时位置
$userfile_name = $_FILES['userfile']['name'];//文件名
$userfile_size = $_FILES['userfile']['size'];//文件大小,字节
$userfile_type = $_FILES['userfile']['type'];//文件类型
if(!is_dir("image")) mkdir ("image", 0700);
$upfile = "image/".$userfile_name;//保存位置
print_r($_FILES);
//move_uploaded_file($userfile,$upfile);//方法1
if(!copy($userfile,$upfile))//方法2
{
echo "上传失败";
exit();
}
echo "上传成功";
echo "<a href="#" onClick="window.history.back();">再上传一张</a>";
}
else{
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data" name="form1">
<input name="MAX_FILE_SIZE" type="hidden" id="MAX_FILE_SIZE" value="1000">
<input name="userfile" type="file" id="userfile">
<input type="submit" name="Submit" value="上传">
</form>
</body>
</html>
<?php }?> php爱好者站 http://www.phpfans.net php基础|php进阶|php模板.
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28