是将image类型数据取出来写到文件中,以文件形式保存,将文件路径存到数据库中,方法见下: function makeattach(fileContentType,filevalue,i) select case fileContentType case "application/msword" ext="doc" case "application/vnd.ms-excel" ext="exl" case "application/vnd.ms-powerpoint" ext="pps" case "application/x-rar-compressed" ext="rar" case "application/x-zip-compressed" ext="zip" case "image/gif" ext="gif" case "image/pjpeg" ext="jpg" case "text/plain" ext="txt" case else ext="x" end select if ext<>"x" then set fso=server.createobject("FileSystemObject") fName="attech"&i&"."&ext Dir="d:\attach\" If fso.FileExists(Dir & fName) Then fso.deletefile Dir & fName If fName<>"" AND NOT fso.FileExists(Dir & fName) Then Set strm1=Server.CreateObject("ADODB.Stream") strm1.Open strm1.Type=1 'Binary strm1.Write filevalue strm1.SaveToFile Dir & fName,2 Set strm1=Nothing end if makeattach=fName end if end function 这个函数有3个输入参数,第一个是文件的contentType,第二个是文件的二进制数值,第三个是个可以区别文件名的变量,先根据contentType确定所存文件的后缀名,然后就是将二进制数值保存成指定文件名的文件,并将文件名作为输出参数返回,将返回的参数作为数据写到mysql的数据库中保存上一页 [1] [2]
|
|