国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

淺析asp無組件上傳并插入到數據庫里_ASP教程

2024-05-04 11:04:11
字體:
來源:轉載
供稿:網友

推薦:如何用ASP顯示ACCESS數據庫的的GIF圖象
寫入:1:把gif圖像文件讀入內存(一個變量strTemp)。2:寫入數據庫。 以下為引用的內容: Dim binTmp() As Byte Dim conn As ADODB.Conn

以下為引用的內容:

<%
Response.Buffer = True
Server.ScriptTimeOut=9999999
On Error Resume Next

%>
<!--#include file="conn.asp"-->
<!--#include file="function.asp"-->
<!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" />
<style type="text/css">
<!--
body,input {font-size:12px;}
-->
</style>
<title>ASP文件上傳</title>
</head>
<body id="body">
<%
checkuser()

ExtName = "xls" '允許擴展名
SavePath = "upload" '保存路徑
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)

SaveFileName = Mid(SaveFile,InstrRev(SaveFile,"") 1)
session("file")=SaveFileName

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)

Dim Conn1,Driver1,DBPath1,Rs1,Sql1
' 建立Connection對象
Set Conn1 = Server.CreateObject("ADODB.Connection")
Driver1 = "Driver={Microsoft Excel Driver (*.xls)};"
DBPath1 = "DBQ=" & Server.MapPath("upload/"&SaveFileName)

'調用Open 方法打開數據庫
Conn1.Open Driver1 & DBPath1

Sql1="Select * From [Sheet1$] "
Set Rs1=Conn1.Execute(Sql1)

IF Rs1.Eof And Rs1.Bof Then
Response.write "沒有找到您需要的數據!!"
Else
Do While Not Rs1.EOF

'插入到數據庫中


OpenDataBase "select * from abc"

if len(rs1(0))=7 then

ctime=left(rs1(0),4)
else

ctime=left(rs1(0),5)
end if

rs.addnew
rs("time")=ctime
rs.update
CloseDataBase()


Rs1.MoveNext
Loop
End IF

Rs1.Close
Set Rs1=nothing
Conn1.Close
Set Conn1=Nothing

'插入到數據庫中結束

Response.write "文件上傳: <span style=""color:red;"">" & SaveFileName & " </span>文件上傳成功!<a href='choise.asp''>繼續上傳文件</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>

分享:解讀asp防SQL注入代碼
以下為引用的內容:dim sql_injdata,SQL_inj,SQL_Get,SQL_Data,Sql_Post SQL_injdata = '|and|exec|insert|select|delete|update|

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 临湘市| 喀什市| 皋兰县| 买车| 合山市| 临颍县| 江阴市| 新营市| 常德市| 西宁市| 武城县| 什邡市| 南丰县| 梁平县| 越西县| 东台市| 西乌珠穆沁旗| 江安县| 陆河县| 新邵县| 西丰县| 玉山县| 乌鲁木齐市| 阜南县| 东丽区| 静宁县| 韩城市| 乌兰察布市| 叶城县| 安新县| 青阳县| 绍兴县| 来凤县| 苏尼特右旗| 衡东县| 宜都市| 溧水县| 上蔡县| 宁津县| 乐陵市| 通河县|