无组件上传图片到数据库中,最完整解决方案

手把手教你用Fiddler模拟2G/3G网络,完成App弱网测试全流程(含脚本配置) 本文详细介绍了如何使用Fiddler工具进行App弱网测试,包括环境搭建、脚本配置和全流程问题定位。通过模拟2G/3G网络环境,开发者可以有效发现并修复网络不稳定导致的用户体验问题,提升App在弱网条件下的性能表现。 阅读详情
'::::::: 此程序属扬子原创 ::::::::::::::::::
':::::: 在sql2000,2000s中测试通过::::::::
':::::::联系我:QQ:21112856,Email:yangzinet@hotmail.com:::::::::
'::::::: http://www.tingfo.net ::::::


up.htm

<!--#include file="inc/domin.asp"-->
<!--#include file="conn.asp"-->
<html>
<head>
<title><% =webname %></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="main.css" type="text/css">
<style type="text/css">
<!--
.tx1 { height: 20px; width: 30px; font-size: 9pt; border: 1px solid; border-color: black black

#000000; color: #0000FF}
-->
</style>

<script language="JavaScript">
<!--
var bgc_on=new Array("#74D738","#FF9C17","#3278AB","#486177","#078C00","#007ECA")
var bgc_off=new Array("#4CAD12","FFB859","5F9FD0","577590","08A700","009FFF")

function turnon(obj1,id){
obj1.style.background=bgc_on[id];
}
function turnoff(obj1,id){
obj1.style.background=bgc_off[id];
}

//-->
</script>
<SCRIPT language=javascript>
function check_input()
{
if (Frm.pic.value=="")
{ alert("请选择要上传的图片");
return false;
}
if (Frm.type.value=="")
{ alert("请选择图片类型");
return false;
}
if (Frm.thetext.value=="")
{ alert("请输入照片说明");
return false;
}
return true;
}
</SCRIPT>
</head>

<body bgcolor="#555555" text="#000000" leftmargin="0" topmargin="0">
<table width=755 cellpadding=0 cellspacing=0 border=0 bgcolor=#ffffff align="center">
<tr>
<td height=100><img src="img/top.gif" align="top">
</table>

<!--#include file="inc/mulu.asp"-->


<table width=755 cellpadding=0 cellspacing=0 border=0 bgcolor=#ffffff align="center" bordercolor=#000000>
<tr>
<td height=400 width=180 bgcolor=#D1E9D5 style="border-right: 1px #0E801E solid">
<table width=100% height=100% cellpadding=0 cellspacing=0 border=0 align="center" bordercolor=#000000>
<tr><td height=30 align="center" class=L15><font color=#E96D08>欢迎你:<% =username %> 管理中心</font>
<tr><td height=23 align="center" class=L15 bgcolor=#4CAD12 style="border-top:0px #0E801E solid; border-bottom:1px #0E801E solid;"><font color=#C2F009 class=yinying>管 理 中 心</font>
<tr><td height=20 class=L13>
<!--#include file="inc/centermulu.asp"-->
<tr><td height=5>
<tr><td>
</table>
<td>
<%
set rs=server.createobject("adodb.recordset")
sql="select * from photo where author='"&username&"'"
rs.open sql,conn,1,1
%>
<table cellpadding=0 cellspacing=0 border=0 width=100% height=100%>
<tr><td height=3>
<tr><td height=3 bgcolor=#ffffff background=img/bj3.gif>
<tr><td height=20 valign="bottom" bgcolor=#eeeeee> 现在位置: 98243班 - 管理中心 - 添加新闻
<tr><td height=3 bgcolor=#eeeeee style="border-bottom: 1px #cccccc solid"><p style="font-size:1pt">
<tr><td height=20 valign="bottom"> <font color=green><% =username %>:你一共上传了 <font color=red><% =rs.recordcount %></font> 张照片</font> <a href="adminphoto.asp"><font color=red><u>管理以前上传的照片</u></font></a>
<tr><td bgcolor=#ffffff valign=top>
<table cellpadding=0 cellspacing=0 border=0 width=95% height=100% align="center">
<form action=addphoto.asp method=post name=Frm onSubmit="return check_input()" enctype="multipart/form-data">
<tr><td height=20 colspan=2>
<tr><td height=25 width=15% align="right" class=L13>选择照片: <td> <input NAME="pic" TYPE="FILE" class="tx1" style="width:300"> <font color=red>拒绝色情、写真图等</font>

<tr><td height=25 width=20% align="right" class=L13>照片分类: <td> <select name="type">
<option selected value="">选择类型</option>
<option value="班级合影">班级合影</option>
<option value="个人照片">个人照片</option>
<option value="恩师照片">恩师照片</option>
<option value="情人照片">情人照片</option>
<option value="友人照片">友人照片</option>
<option value="其他照片">其他照片</option>
</select>

<tr><td height=25 width=20% align="right" class=L13>照片说明: <td> <textarea name="thetext" cols="46" rows="7" style="border:1px double rgb(88,88,88);font:9pt">
</textarea> <font color=red>最多20个字符</font>
<tr><td height=5 colspan=2>
<tr><td height=25 colspan=2 align="center">
<input type="submit" name="Submit" value=" 提 交 " style="border:1px double rgb(88,88,88);font:9pt">
   <input type="reset" name="Reset" value=" 重 写 " style="border:1px double rgb(88,88,88);font:9pt">
<tr><td colspan=2>
</tr></form>
</table>
</table>

</table>
<!--#include file="inc/footer.asp"-->
</body>
</html>

fupload.inc

<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>
'限制上传图片大小
Dim UploadSizeLimit

'********************************** 得到上传数据 **********************************
Function GetUpload()
Dim Result
Set Result = Nothing
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then 'Request method must be "POST"
Dim CT, PosB, Boundary, Length, PosE
CT = Request.ServerVariables("HTTP_Content_Type") 'reads Content-Type header
If LCase(Left(CT, 19)) = "multipart/form-data" Then 'Content-Type header must be "multipart/form-data"
'This is upload request.
'Get the boundary and length from Content-Type header
PosB = InStr(LCase(CT), "boundary=") 'Finds boundary
If PosB > 0 Then Boundary = Mid(CT, PosB + 9) 'Separetes boundary
Length = CLng(Request.ServerVariables("HTTP_Content_Length")) 'Get Content-Length header
if "" & UploadSizeLimit<>"" then
UploadSizeLimit = clng(UploadSizeLimit)
if Length > UploadSizeLimit then
' on error resume next 'Clears the input buffer
' response.AddHeader "Connection", "Close"
' on error goto 0
Request.BinaryRead(Length)
Err.Raise 2, "GetUpload", "Upload size " & FormatNumber(Length,0) & "B exceeds limit of " & FormatNumber(UploadSizeLimit,0) & "B"
exit function
end if
end if

If Length > 0 And Boundary <> "" Then 'Are there required informations about upload ?
Boundary = "--" & Boundary
Dim Head, Binary
Binary = Request.BinaryRead(Length) 'Reads binary data from client

'Retrieves the upload fields from binary data
Set Result = SeparateFields(Binary, Boundary)
Binary = Empty 'Clear variables
Else
Err.Raise 10, "GetUpload", "Zero length request ."
End If
Else
Err.Raise 11, "GetUpload", "No file sent."
End If
Else
Err.Raise 1, "GetUpload", "Bad request method."
End If
Set GetUpload = Result
End Function


Function SeparateFields(Binary, Boundary)
Dim PosOpenBoundary, PosCloseBoundary, PosEndOfHeader, isLastBoundary
Dim Fields
Boundary = StringToBinary(Boundary)

PosOpenBoundary = InstrB(Binary, Boundary)
PosCloseBoundary = InstrB(PosOpenBoundary + LenB(Boundary), Binary, Boundary, 0)

Set Fields = CreateObject("Scripting.Dictionary")

Do While (PosOpenBoundary > 0 And PosCloseBoundary > 0 And Not isLastBoundary)
'Header and file/source field data
Dim HeaderContent, FieldContent
'Header fields
Dim Content_Disposition, FormFieldName, SourceFileName, Content_Type
'Helping variables
Dim Field, TwoCharsAfterEndBoundary
'Get end of header
PosEndOfHeader = InstrB(PosOpenBoundary + Len(Boundary), Binary, StringToBinary(vbCrLf + vbCrLf))

'Separates field header
HeaderContent = MidB(Binary, PosOpenBoundary + LenB(Boundary) + 2, PosEndOfHeader - PosOpenBoundary - LenB(Boundary) - 2)

'Separates field content
FieldContent = MidB(Binary, (PosEndOfHeader + 4), PosCloseBoundary - (PosEndOfHeader + 4) - 2)

'Separates header fields from header
GetHeadFields BinaryToString(HeaderContent), Content_Disposition, FormFieldName, SourceFileName, Content_Type

'Create one field and assign parameters
Set Field = CreateUploadField()
Field.Name = FormFieldName
Field.ContentDisposition = Content_Disposition
Field.FilePath = SourceFileName
Field.FileName = GetFileName(SourceFileName)
Field.ContentType = Content_Type
Field.Value = FieldContent
Field.Length = LenB(FieldContent)


Fields.Add FormFieldName, Field

'Is this ending boundary ?
TwoCharsAfterEndBoundary = BinaryToString(MidB(Binary, PosCloseBoundary + LenB(Boundary), 2))
'Binary.Mid(PosCloseBoundary + Len(Boundary), 2).String
isLastBoundary = TwoCharsAfterEndBoundary = "--"
If Not isLastBoundary Then 'This is not ending boundary - go to next form field.
PosOpenBoundary = PosCloseBoundary
PosCloseBoundary = InStrB(PosOpenBoundary + LenB(Boundary), Binary, Boundary )
End If
Loop
Set SeparateFields = Fields
End Function

'********************************** Utilities **********************************
Function BinaryToString(str)
strto = ""
for i=1 to lenb(str)
if AscB(MidB(str, i, 1)) > 127 then
strto = strto & chr(Ascb(MidB(str, i, 1))*256+Ascb(MidB(str, i+1, 1)))
i = i + 1
else
strto = strto & Chr(AscB(MidB(str, i, 1)))
end if
next
BinaryToString=strto
End Function

Function StringToBinary(String)
Dim I, B
For I=1 to len(String)
B = B & ChrB(Asc(Mid(String,I,1)))
Next
StringToBinary = B
End Function

'Separates header fields from upload header
Function GetHeadFields(ByVal Head, Content_Disposition, Name, FileName, Content_Type)
Content_Disposition = LTrim(SeparateField(Head, "content-disposition:", ";"))
Name = (SeparateField(Head, "name=", ";")) 'ltrim
If Left(Name, 1) = """" Then Name = Mid(Name, 2, Len(Name) - 2)
FileName = (SeparateField(Head, "filename=", ";")) 'ltrim
If Left(FileName, 1) = """" Then FileName = Mid(FileName, 2, Len(FileName) - 2)
Content_Type = LTrim(SeparateField(Head, "content-type:", ";"))
End Function

'Separets one filed between sStart and sEnd
Function SeparateField(From, ByVal sStart, ByVal sEnd)
Dim PosB, PosE, sFrom
sFrom = LCase(From)
PosB = InStr(sFrom, sStart)
If PosB > 0 Then
PosB = PosB + Len(sStart)
PosE = InStr(PosB, sFrom, sEnd)
If PosE = 0 Then PosE = InStr(PosB, sFrom, vbCrLf)
If PosE = 0 Then PosE = Len(sFrom) + 1
SeparateField = Mid(From, PosB, PosE - PosB)
Else
SeparateField = Empty
End If
End Function

'Separetes file name from the full path of file
Function GetFileName(FullPath)
Dim Pos, PosF
PosF = 0
For Pos = Len(FullPath) To 1 Step -1
Select Case Mid(FullPath, Pos, 1)
Case "/", "/": PosF = Pos + 1: Pos = 0
End Select
Next
If PosF = 0 Then PosF = 1
GetFileName = Mid(FullPath, PosF)
End Function
</SCRIPT>
<SCRIPT RUNAT=SERVER LANGUAGE=JSCRIPT>
//The function creates Field object.
function CreateUploadField(){ return new uf_Init() }
function uf_Init(){
this.Name = null
this.ContentDisposition = null
this.FileName = null
this.FilePath = null
this.ContentType = null
this.Value = null
this.Length = null
}
</SCRIPT>

addphoto.asp
<!--#include file="conn.asp"-->
<!--#include file="inc/domin.asp"-->
<!--#include file="fupload.inc"-->
<%
if Request.ServerVariables("REQUEST_METHOD") = "POST" Then
Dim Fields
UploadSizeLimit=100000
Set Fields = GetUpload()
dim Field
For Each Field In Fields.Items
select case Field.name
case "thetext" sss=BinaryToString(Field.value)
case "type" fff=BinaryToString(Field.value)
case "submit" submit=BinaryToString(Field.value)
case "pic"
filename=field.FileName
fileContentType=field.ContentType
filevalue=field.value
end select
next
'---------------
if filename<>"" and fileContentType<>"image/gif" and

fileContentType<>"image/pjpeg" then
%>
<center>
<br><br>
<font color=red size=3>上传的照片应该为GIF或JPG文件!</font><br><br>
<input type="button" value="重填" onclick="history.go( -1 );return

true;">
</center>
<%
else
'------------
'开始输入
'-----------
response.write sss
response.write"<br>"
response.write fff
set rs=server.createobject("ADODB.recordset")
sql = "select * from tb where theid is null"
rs.Open sql,conn,3,3
rs.addnew
rs("author")=username
rs("thetext")=sss
rs("types")=fff
rs("hits")=1
rs("posttime")=now()
rs("photo").appendchunk filevalue

rs.update
rs.close
%>
<br><br>
<center><font color=red

size=3>成功输入个人基本档案!</font><br><br><form method="post"

action="personinf.asp"><input type="submit" value="返回"></form>
</center>
<%
end if
end if
%>


showpic.asp
<!--#include file="conn.asp"-->
<%
id=Request("id")
set rs=server.CreateObject("adodb.recordset")
sql="SELECT * FROM tb where theid="&id
rs.Open sql,conn,1,3
response.contenttype="image/gif"
Response.BinaryWrite rs("photo")
%>

ASP和PHP图片上传及存储到Access数据库完整解决方案 在数字时代,图片作为丰富网站内容、提升用户体验的重要元素,其上传功能是各类网站不可或缺的一部分。应用场景包括但不限于社交媒体、电子商务、在线相册、内容管理系统(CMS)等。图片上传能够使用户分享个人图片,为平台带来内容上的丰富性和互动性。图片上传通常可以通过多种技术手段实现,包括但不限于表单上传、Ajax上传、以及使用无组件上传类。ASP主要通过标准的HTML表单结合HTTP POST方法来实现文件上传。尽管简单易用,但这种方式需要服务器端的脚本语言(如ASP)来处理上传的数据。 阅读详情

相关推荐

ASP无组件上传工具包:UTF-8与GB2312双编码支持,含单文件、多文件及表单字段解析示例

一套开箱即用的ASP无组件文件上传解决方案,核心是UpLoadClass.asp上传类,不依赖Server.createObject等服务器组件,适合IIS经典ASP环境部署。提供三套完整可运行演示:demo1为UTF-8编码下的单文件快速上传;demo2基于GB2312编码,支持表单字段读取、文件类型校验、大小限制等实用功能;demo3实现多文件批量上传处理。配套包含上传结果页(upload.asp)、文件列表页(uplist.asp)、数据库模板(UploadClass.mdb)、CSS样式(works

a1b2c的博客 185

VBScript文件上传

好用的VBScript文件上传代码,希望给你带来方便!

ASP无组件文件上传教程.zip

本文还有配套的精品资源,点击获取 简介:ASP无组件上传是一个在不使用外部组件的情况下,通过ASP脚本实现文件上传的方法。关键步骤包括设计HTML表单、处理HTTP POST请求、解析上传的文件数据、安全地保存文件,并向用户反馈上传结果。本教程提供了实现无组件上传的核心概念和安全实践,特别是针对图像文件上传的特殊情况,给出了基础的实现脚本和必要的安全措施。 1. ...

weixin_42610671的博客 803

DreamweaverCS4无组件上传插件

ASP VBSCRIPT 无组件上传 是一个ASP模块的无组件上传插件,该插件调用简单,采用传递上传结果的方式获取文件名。不会破坏修改Dreamweaver CS3、CS4本身生成的代码,非常适合用来做各种上传开发工作。 插件类型:服务器行为插件 支持语言:ASP VBSCRIPT 支持版本:Dreamweaver CS3/CS4 插件性质:免费插件 插件作者:Adobe Dreamweaver CS3/CS4 中文技术交流中心 官方网址:http://www.adobe-dreamweaver.cn

【亲测免费】 图片管理系统-aspaccess-相册-支持图片批量上传

图片管理系统-aspaccess-相册-支持图片批量上传 去发现同类优质开源项目:https://gitcode.com/ 项目介绍 在数字化时代,图片管理成为许多企业和个人不可或缺的需求。今天,我要为您介绍的是一套功能全面、易于使用的图片管理系统——aspaccess相册。该系统基于ASP和ACCESS环境开发,融合了DIV+CSS+AJAX技术,操作界面友好,即使是小白用户也能够轻松上手。 项...

gitblog_06776的博客 855

ASP 单文件上传无组件代码

ASP 单文件上传无组件代码,直接使用,已经纠错。

klxtx1234的专栏 1657

ASP手机网站拍照上传代码

ASP手机网站拍照上传代码 【下载地址】ASP手机网站拍照上传代码 这款ASP手机网站拍照上传源码为开发者提供了便捷的图片上传解决方案。用户可以直接通过手机拍照并上传图片,或从相册中选择图片进行上传,支持一次性上传多张图片。源码易于部署,只需解压并上传到服务器,配置好数据库连接即可使用。该源码旨在帮助开发者快速实现图片上...

gitblog_06788的博客 354

html 无组件上传图片,无组件上传图片数据库中,完整解决方案

::::::: 此程序属扬子原创 :::::::::::::::::::::::: 在sql2000,2000s中测试通过:::::::::::::::联系我:qq:21112856,email:yangzinet@hotmail.com:::::::::::::::: http://www.tingfo.net ::::::up.htm.tx1 { height: 20px; width: 30...

weixin_30471013的博客 327

化境ASP无组件上传

化境ASP无组件上传类 - upload_5xsoft 使用手册 2.0  [ 点此下载 ]   目 录 1.Whats New?2.关于 upload_5xsoft3

bqw_5189的专栏 3042

基于ASP+ ACCESS的上传文件管理软件

基于ASP+ ACCESS的上传文件管理软件

ASP技巧(1)

 如何保护网站安全,防止FSO破坏简单版C#连接ACCESS中文的无组件文件上传ASP函数一个利用adsi得到局域网信息的asp文件根据需要动态include不同的文件让自定义文件下载支持断点续传用数组实现数据记录的批量录入方法上传的进度条 实时反映上传情况用ASP动态生成JavaScript的表单验证代码[图文] 在线实时开通WEB及FTP源程序经典的分页完整程序+注释ASP网站远程客户实现E

rzwince2的专栏 777

XMLHTTP下载远程数据输出到浏览器 选择自 oydj 的 Blog

利用xmlhttp对象获取远程的数据,然后用二进制输出到客户浏览器,让客户下载数据,此例从某一远程服务器获取一个压缩包,并且输出到浏览器提供客户下载.程序代码:---------------------------------------------------------------------------欧阳东杰 创作 (转载请保留此信息)www.cnsxml.comQQ:2596812 

hannibal7188616的专栏 851

ASP手机网站拍照上传代码:简化移动端图片上传流程

ASP手机网站拍照上传代码:简化移动端图片上传流程 【下载地址】ASP手机网站拍照上传代码 这款ASP手机网站拍照上传源码为开发者提供了便捷的图片上传解决方案。用户可以直接通过手机拍照并上传图片,或从相册中选择图片进行上传,支持一次性上传多张图片。源码易于部署,只需解压并上传到服务器,配置好数据库连接即可使用。该源码旨在...

gitblog_06737的博客 806

大文件分段上传

の吟清手记我是风中的落叶,看我如何飞翔 Im a leaf on the wind,watch how i soar. 理想空间 Blog XNA Tags Selected Content Guestbook Link Music Login

zgh2002007的专栏 4578

asp上传视频

简单的应用到化境官方站点下载压缩文件,其中里面有例题 不过我这里是重新编辑的无组件上传,增添了如下内容: 1,支持图片、音频、视频、压缩等各类型文件的上传(可自定义限制的格式文件) 2,对不同类型文件的文件夹归类(按照文件类型建立文件夹,并按“年-月”建立子文件夹) 3,上传的文件名不再采用流水号(这样对搜索不好),当然也加了随机数 4,还有功能程式的说明,具体看文件内容 声明:既然...

weixin_30877227的博客 240

VBScript文件上传类的实现与应用

VBScript(Visual Basic Scripting Edition)是一种轻量级的脚本语言,由微软公司开发。它继承了Visual Basic的语法,专为快速开发小型脚本和Web应用程序的嵌入式脚本而设计。由于其简单易学的特性,VBScript广泛应用于Windows环境中的自动化任务、客户端脚本以及早期的ASP服务器端编程中。

weixin_33506815的博客 655

实现ASP与ACCESS数据库图片上传及显示功能

ASP(Active Server Pages)是一种服务器端脚本环境,用于创建动态交互式网页。它允许开发者将HTML页面与脚本代码相结合,以生成动态内容。ASP文件通常以.asp为扩展名,并包含VBScript或JavaScript代码,这些代码在服务器端执行,而不是在用户浏览器中执行。服务器端接收到表单数据后,通常使用脚本语言如PHP、ASP、Node.js等来处理。数据处理包括但不限于以下步骤:验证输入:确保所有必填字段都已正确填写。

weixin_42583683的博客 371
上一篇: 三种禁用FileSystemObject组件的方法
下一篇: 利用FSO取得BMP,JPG,PNG,GIF文件信息
oydj
博客等级 码龄24年 2粉丝 14原创
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值