求一个asp手机上传图片的源文件!

求一个asp手机上传图片的源文件!类似这样的... 求一个asp手机上传图片的源文件!类似这样的 展开
 我来答
百度网友50f744e
推荐于2016-01-09 · TA获得超过135个赞
知道小有建树答主
回答量:311
采纳率:54%
帮助的人:112万
展开全部
<%
Response.Buffer = true
Server.ScriptTimeOut=9999999
On Error Resume next
%>
<!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" />
<meta http-equiv="Content-Language" content="zh-cn" />
<meta content="all" name="robots" />
<meta name="author" content="木目,Woodeye" />
<meta name="description" content="木目asp文件上传工具" />
<meta name="keywords" content="木目,asp,Upload,文件上传" />
<style type="text/css">
<!--
body,input {font-size:12px;}
-->
</style>
<title>木目asp文件上传工具</title>
</head>
<body id="body">
<%
ExtName = "jpg,gif,png,txt,rar,zip,doc,bmp" '允许扩展名
SavePath = "image" '保存路径
If Right(SavePath,1)<>"/" Then SavePath=SavePath&"/" '在目录后加(/)
CheckAndCreateFolder(SavePath)

UpLoadAll_a = Request.TotalBytes '取得客户端全部内容
If(UpLoadAll_a>0) Then
Set UploadStream_c = Server.CreateObject("ADODB.Stream")
UploadStream_c.Type = 1
UploadStream_c.Open
UploadStream_c.Write Request.BinaryRead(UpLoadAll_a)
UploadStream_c.Position = 0

FormDataAll_d = UploadStream_c.Read
CrLf_e = chrB(13)&chrB(10)
FormStart_f = InStrB(FormDataAll_d,CrLf_e)
Formend_g = InStrB(FormStart_f+1,FormDataAll_d,CrLf_e)

Set FormStream_h = Server.Createobject("ADODB.Stream")
FormStream_h.Type = 1
FormStream_h.Open
UploadStream_c.Position = FormStart_f + 1
UploadStream_c.CopyTo FormStream_h,Formend_g-FormStart_f-3
FormStream_h.Position = 0
FormStream_h.Type = 2
FormStream_h.CharSet = "GB2312"
FormStreamText_i = FormStream_h.Readtext
FormStream_h.Close

Filename_j = Mid(FormStreamText_i,InstrRev(FormStreamText_i,"\")+1,Formend_g)

If(CheckFileExt(Filename_j,ExtName)) Then
SaveFile = Server.MapPath(SavePath & Filename_j)

If Err Then
Response.Write "文件上传: <span style=""color:red;"">文件上传出错!</span> <a href=""" & Request.ServerVariables("url") &""">重新上传文件</a><br />"
Err.Clear
Else
SaveFile = CheckFileExists(SaveFile)

k=Instrb(FormDataAll_d,CrLf_e&CrLf_e)+4
l=Instrb(k+1,FormDataAll_d,leftB(FormDataAll_d,FormStart_f-1))-k-2
FormStream_h.Type=1
FormStream_h.Open
UploadStream_c.Position=k-1
UploadStream_c.CopyTo FormStream_h,l
FormStream_h.SaveToFile SaveFile,2

SaveFilename = Mid(SaveFile,InstrRev(SaveFile,"\")+1)
Response.write "文件上传: <span style=""color:red;"">" & SaveFilename & " </span>文件上传成功! <a href=""" & Request.ServerVariables("url") &""">继续上传文件</a><br />"
end If
Else
Response.write "文件上传: <span style=""color:red;"">文件格式不正确!</span> <a href=""" & Request.ServerVariables("url") &""">重新上传文件</a><br />"
end If

Else
%>
<script language="Javascript">
<!--
function ValidInput()
{

if(document.upform.upfile.value=="")
{
alert("请选择上传文件!")
document.upform.upfile.focus()
return false
}
return true
}
// -->
</script>
<form action='<%= Request.ServerVariables("url") %>' method='post' name="upform" onsubmit="return ValidInput()" enctype="multipart/form-data">
文件上传:
<input type='file' name='upfile' size="40"> <input type='submit' value="上传">
</form>
<%
end if
Set FormStream_h = Nothing
UploadStream.Close
Set UploadStream = Nothing
%>
</body>
</html>
<%
'判断文件类型是否合格
Function CheckFileExt(Filename,ExtName) '文件名,允许上传文件类型
FileType = ExtName
FileType = Split(FileType,",")
For i = 0 To Ubound(FileType)
If LCase(Right(Filename,3)) = LCase(FileType(i)) then
CheckFileExt = true
Exit Function
Else
CheckFileExt = False
end if
next
end Function

'检查上传文件夹是否存在,不存在则创建文件夹
Function CheckAndCreateFolder(FolderName)
fldr = Server.Mappath(FolderName)
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(fldr) Then
fso.CreateFolder(fldr)
end If
Set fso = Nothing
end Function

'检查文件是否存在,重命名存在文件
Function CheckFileExists(FileName)
Set fso=Server.CreateObject("Scripting.FileSystemObject")
If fso.FileExists(SaveFile) Then
i=1
msg=True
Do While msg
CheckFileExists = Replace(SaveFile,Right(SaveFile,4),"_" & i & Right(SaveFile,4))
If not fso.FileExists(CheckFileExists) Then
msg=False
end If
i=i+1
Loop
Else
CheckFileExists = FileName
End If
Set fso=Nothing
End Function
%>
AiPPT
2024-09-19 广告
作为北京饼干科技有限公司的工作人员,关于AIPPT免费生成PPT的功能,我可以简要介绍如下:AIPPT是一款基于人工智能技术的PPT制作工具,它为用户提供了免费生成PPT的便捷服务。用户只需简单输入PPT的主题或内容大纲,AIPPT便能智能... 点击进入详情页
本回答由AiPPT提供
花满楼灬煜
2014-09-04 · TA获得超过107个赞
知道答主
回答量:29
采纳率:100%
帮助的人:18.7万
展开全部
<input type="file" name="file1" id="file1">

后台处理跟网站上的处理是一样的!
追问
要完整的代码?
那个+号怎么实现?
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式