请教tripofdream(夢之旅)和其他仁兄有关文件操作问题
兄弟你好,上次多谢你的帮助,我还有一点疑问再次请你帮忙.
我把你的第二个例子进行了修改,由于我对文件操作不太熟悉,
我想问一下
(1)对于form中的file类型域的操作是否同form中text类型操作一样,我怎么不成功呢?
(2)getupload()具体应该怎么来写?还(3)有下面这一块应该怎么来写:
'Fields("File1").ContentType - content type of File1 field
'Fields("File1").Value.String - File1 field converted to a string
'Fields("File1").Value.ByteArray - File1 field as safearray to store in binary RS field or file
'Fields("Comments").Value.String - value of Comments field
修改后的文件如下:
文件1(file1):index.asp
<html>
<head>
<title>上传</title>
</head>
<body>
<Table>
<form method=post ENCTYPE="multipart/form-data" action="save.asp">
<TR><TD></TD><TD Align=Right><input type="submit" Name="Action" value="Upload the file >>"></TD></TR>
<TR><TD>文件</TD><TD><input type="file" name="DBFile"></TD></TR>
<TR><TD>标题</TD><TD><input size="60" name="Title" value="Title of the file."></TD></TR>
<TR><TD>描述</TD><TD><textarea cols="60" rows="8" name="Description">Type description of the file.</textarea></TD></TR>
</form>
</Table>
</body>
</html>
'======================================================================
文件2(file2)---save.asp
<%
Server.ScriptTimeout = 200
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
Dim Fields
' 问题开始(question begin)??????????????????????????????
Set Fields = GetUpload()
'Fields("File1").ContentType - content type of File1 field
'Fields("File1").Value.String - File1 field converted to a string
'Fields("File1").Value.ByteArray - File1 field as safearray to store in binary RS field or file
'Fields("Comments").Value.String - value of Comments field
'问题结束(question end)????????????????????????????
If Err = 0 Then
Response.Write DBSaveUpload(Fields)
Else
Response.Write Err.Description
End If
Fields = Empty
End If
function DBSaveUpload(Fields)
dim Conn, RS
set conn=server.createobject("adodb.connection")
conn.open "Driver={Microsoft Access Driver (*.mdb)};DBQ="&sever.mappath("db/upload.mdb")
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open "Upload", Conn,3,3
RS.AddNew
RS("UploadDT") = Now()
RS("RemoteIP") = Request.ServerVariables("REMOTE_ADDR")
RS("ContentType") = Fields("DBFile").ContentType
RS("SouceFileName") = Fields("DBFile").FileName
RS("Description") = BinaryToString(Fields("Description").Value)
RS("Title") = BinaryToString(Fields("Title").Value)
RS("Data").AppendChunk Fields("DBFile").Value
RS.Update
RS.Close
set rs=nothing
Conn.Close
set conn=nothing
DBSaveUpload = "<br>File <b>" & Fields("DBFile").FileName & "</b>, length : <b>" & Fields("DBFile").Length & " B</b> was saved to the database. "
end function
%>