当前位置: 网学 > 编程文档 > PHP > 正文

php中关于普通表单多文件上传的处理方法

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 13/06/21
''.$this->up_max.''K 的文件!'');
}
}
} else {
foreach ($this->up_files as $up_file) {
$up_ext = end(explode(''.'', $up_file[''name'']));

$up_allw = false;
foreach ($this->up_ext as $ext) {
if ($up_ext == $ext) {
$up_allw = true; break;
}
}
!$up_allw && exit(''不允许上传.''.$up_ext.''格式的文件!'');

if ($up_file[''size''] / 1024 > $this->up_max) {
exit(''不允许上传大于 ''.$this->up_max.''K 的文件!'');
}
}
}

$this->Uploading();
}

private function Uploading() {
if (IO::DIRCreate($this->up_dir)) {
if (chmod($this->up_dir, 0777)) {
if (!empty($this->up_files)) {
foreach ($this->up_files as $up_file) {
if (is_uploaded_file($up_file[''tmp_name''])) {
$file_name = $up_file[''name''];
if ($this->up_rename) {
$file_ext = end(explode(''.'', $file_name));
$file_rnd = substr(md5(uniqid()), mt_rand(0, 26), 6);
$file_name = date(''ymdHis'').''_''.$file_rnd.''.''.$file_ext;
}
$file_name = $this->up_dir.''/''.$file_name;

if (move_uploaded_file($up_file[''tmp_name''], $file_name)) {
$this->up_ret[] = str_replace(WEBSITE_DIRROOT, '''', $file_name);
} else {
exit(''文件上传失败!'');
}
}
}
}
} else {
exit(''未开启写入权限!'');
}
} else {
exit(''上传目录创建失败!'');
}
}

public function GetUpload() {
return empty($this->up_ret) ? false : $this->up_ret;
}

function __destruct() {}
}
?>


asp:
复制代码 代码如下:
<%
Class MultiUpload

REM PUBLIC-VARIANT

Public Form, IsFinished
Private bvbCrlf, bSeparate, fPassed, formData, fileType, fileSize, folderPath, _
fRename, fIMGOnly, itemCount, chunkSize, bTime, sErrors, sAuthor, sVersion
Private itemStart(), itemLength(), dataStart(), dataLength(), itemName(), itemData(), extenArr(), httpArr()

REM CLASS-INITIALIZE

Private Sub Class_Initialize
Call InitVariant
Server.ScriptTimeOut = 1800
Set Form = Server.CreateObject("Scripting.Dictionary")
sAuthor = "51JS.COM-ZMM"
sVersion = "MultiUpload Class 3.0"
End Sub

REM CLASS-ATTRIBUTES

Public Property Let AllowType(byVal sType)
Dim regEx
Set regEx = New RegExp
regEx.Pattern = "^(\w+\|)*\w+$"
regEx.Global = False
regEx.IgnoreCase = True
If regEx.Test(sType) Then fileType = "|" & Ucase(sType) & "|"
Set regEx = Nothing
End Property

Public Property Let MaxSize(byVal sSize)
If IsNumeric(sSize) Then fileSize = CDbl(FormatNumber(CCur(sSize), 2))
End Property

Public Property Let SaveFolder(byVal sFolder)
folderPath = sFolder
End Property

Public Property Let CommonPassed(byVal bCheck)
fPassed = bCheck
End Property

Public Property Let FileRenamed(byVal bRename)
fRename = bRename
End Property

Public Property Let FileIsAllImg(byVal bOnly)
fIMGOnly = bOnly
End Property

Public Property Get SaveFolder
SaveFolder = folderPath
End Property

Public Property Get FileRenamed
FileRenamed = fRename
End Property

Public Property Get FileIsAllImg
FileIsAllImg = fIMGOnly
End Property

Public Property Get ErrMessage
ErrMessage = sErrors
End Property

Public Property Get ClsAuthor
ClsAuthor = sAuthor
End Property

Public Property Get ClsVersion
ClsVersion = sV

网学推荐

免费论文

原创论文

浏览:
设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
湘ICP备09003080号