主题:  图片上传的插件不好用!!!!!!

whzooo

职务:普通成员
等级:1
金币:0.0
发贴:102
注册:2002/10/6 12:08:07
#12003/4/21 17:38:16

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>

<%
'*** File Upload to: images, Extensions: "", Form: form1, Redirect: "", "file", "", "over"
'*** Pure ASP File Upload Modify Version by xPilot-----------------------------------------------------
' Copyright 2000 (c) George Petrov
'
' Script partially based on code from Philippe Collignon
' (http://www.asptoday.com/articles/20000316.htm)
'
' New features from GP:
' * Fast file save with ADO 2.5 stream object
' * new wrapper functions, extra error checking
' * UltraDev Server Behavior extension
'
' Copyright 2001-2002 (c) Modify by xPilot
' *** Date: 12/15/2001 ***
' *** 支持所有双字节文件名,而且修复了原函数中遇到空格也会自动截断文件名的错误! ***
' *** 保证百分百以原文件名保存上传文件!***
' *** Welcome to visite pilothome.yeah.net or mail xpilot@21cn.com to me!***
'
' Version: 2.0.1 Beta for GB2312,BIG5,Japan,Korea ...
'------------------------------------------------------------------------------
Sub BuildUploadRequest(RequestBin,UploadDirectory,storeType,sizeLimit,nameConflict)
'Get the boundary
PosBeg = 1
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
if PosEnd = 0 then
Response.Write "Form was submitted with no ENCTYPE=""multipart/form-data""
"
Response.Write "Please correct the form attributes and try again."
Response.End
end if
'Check ADO Version
    set checkADOConn = Server.CreateObject("ADODB.Connection")
    adoVersion = CSng(checkADOConn.Version)
    set checkADOConn = Nothing
    if adoVersion < 2.5 then
Response.Write "You don't have ADO 2.5 installed on the server.
"
Response.Write "The File Upload extension needs ADO 2.5 or greater to run properly.
"
Response.Write "You can download the latest MDAC (ADO is included) from www.microsoft.com/data
"
Response.End
    end if        
'Check content length if needed
    Length = CLng(Request.ServerVariables("HTTP_Content_Length")) 'Get Content-Length header
    If "" & sizeLimit <> "" Then
sizeLimit = CLng(sizeLimit)
If Length > sizeLimit Then
Request.BinaryRead (Length)
Response.Write "Upload size " & FormatNumber(Length, 0) & "B exceeds limit of " & FormatNumber(sizeLimit, 0) & "B"
Response.End
End If
End If
boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
boundaryPos = InstrB(1,RequestBin,boundary)
'Get all data inside the boundaries
Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--")))
'Members variable of objects are put in a dictionary object
Dim UploadControl
Set UploadControl = CreateObject("Scripting.Dictionary")
'Get an object name
Pos = InstrB(BoundaryPos,RequestBin,getByteString("Content-Disposition"))
Pos = InstrB(Pos,RequestBin,getByteString("name="))
PosBeg = Pos+6
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
Name = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
PosFile = InstrB(BoundaryPos,RequestBin,getByteString("filename="))
PosBound = InstrB(PosEnd,RequestBin,boundary)
'Test if object is of file type
If PosFile<>0 AND (PosFile 'Get Filename, content-type and content of file
PosBeg = PosFile + 10
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
FileName = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
FileName = Mid(FileName,InStrRev(FileName,"\")+1)
'Add filename to dictionary object
UploadControl.Add "FileName", FileName
Pos = InstrB(PosEnd,RequestBin,getByteString("Content-Type:"))
PosBeg = Pos+14
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
'Add content-type to dictionary object
ContentType = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
UploadControl.Add "ContentType",ContentType
'Get content of object
PosBeg = PosEnd+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
value = FileName
valueBeg = PosBeg-1
valueLen = PosEnd-Posbeg
Else
'Get content of object
Pos = InstrB(Pos,RequestBin,getByteString(chr(13)))
PosBeg = Pos+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
value = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
valueBeg = 0
valueEnd = 0
End If
'Add content to dictionary object
UploadControl.Add "value" , value    
UploadControl.Add "valueBeg" , valueBeg
UploadControl.Add "valueLen" , valueLen    
'Add dictionary object to main dictionary
UploadRequest.Add name, UploadControl    
'Loop to next object
BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary)
Loop

GP_keys = UploadRequest.Keys
for GP_i = 0 to UploadRequest.Count - 1
GP_curKey = GP_keys(GP_i)
'Save all uploaded files
if UploadRequest.Item(GP_curKey).Item("FileName") <> "" then
GP_value = UploadRequest.Item(GP_curKey).Item("value")
GP_valueBeg = UploadRequest.Item(GP_curKey).Item("valueBeg")
GP_valueLen = UploadRequest.Item(GP_curKey).Item("valueLen")

if GP_valueLen = 0 then
Response.Write "An error has occured saving uploaded file!

"
Response.Write "Filename: " & Trim(GP_curPath) & UploadRequest.Item(GP_curKey).Item("FileName") & "
"
Response.Write "File does not exists or is empty.
"
Response.Write "Please correct and try again"
          response.End
     end if

'Create a Stream instance
Dim GP_strm1, GP_strm2
Set GP_strm1 = Server.CreateObject("ADODB.Stream")
Set GP_strm2 = Server.CreateObject("ADODB.Stream")

'Open the stream
GP_strm1.Open
GP_strm1.Type = 1 'Binary
GP_strm2.Open
GP_strm2.Type = 1 'Binary

GP_strm1.Write RequestBin
GP_strm1.Position = GP_valueBeg
GP_strm1.CopyTo GP_strm2,GP_valueLen

'Create and Write to a File
GP_curPath = Request.ServerVariables("PATH_INFO")
GP_curPath = Trim(Mid(GP_curPath,1,InStrRev(GP_curPath,"/")) & UploadDirectory)
if Mid(GP_curPath,Len(GP_curPath),1) <> "/" then
GP_curPath = GP_curPath & "/"
end if
GP_CurFileName = UploadRequest.Item(GP_curKey).Item("FileName")
GP_FullFileName = Trim(Server.mappath(GP_curPath))& "\" & GP_CurFileName
'Check if the file alreadu exist
GP_FileExist = false
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(GP_FullFileName)) Then
GP_FileExist = true
End If
if nameConflict = "error" and GP_FileExist then
Response.Write "File already exists!

"
Response.Write "Please correct and try again"
                GP_strm1.Close
                GP_strm2.Close
          response.End
end if
if ((nameConflict = "over" or nameConflict = "uniq") and GP_FileExist) or (NOT GP_FileExist) then
if nameConflict = "uniq" and GP_FileExist then
Begin_Name_Num = 0
while GP_FileExist
Begin_Name_Num = Begin_Name_Num + 1
GP_FullFileName = Trim(Server.mappath(GP_curPath))& "\" & fso.GetBaseName(GP_CurFileName) & "_" & Begin_Name_Num & "." & fso.GetExtensionName(GP_CurFileName)
GP_FileExist = fso.FileExists(GP_FullFileName)
wend
UploadRequest.Item(GP_curKey).Item("FileName") = fso.GetBaseName(GP_CurFileName) & "_" & Begin_Name_Num & "." & fso.GetExtensionName(GP_CurFileName)
                    UploadRequest.Item(GP_curKey).Item("value") = UploadRequest.Item(GP_curKey).Item("FileName")
end if
on error resume next
GP_strm2.SaveToFile GP_FullFileName,2
if err then
Response.Write "An error has occured saving uploaded file!

"
Response.Write "Filename: " & Trim(GP_curPath) & UploadRequest.Item(GP_curKey).Item("FileName") & "
"
Response.Write "Maybe the destination directory does not exist, or you don't have write permission.
"
Response.Write "Please correct and try again"
         err.clear
                GP_strm1.Close
                GP_strm2.Close
          response.End
     end if
            GP_strm1.Close
            GP_strm2.Close
            if storeType = "path" then
                UploadRequest.Item(GP_curKey).Item("value") = GP_curPath & UploadRequest.Item(GP_curKey).Item("value")
            end if
on error goto 0
end if
end if
next

End Sub

'把普通字符串转成二进制字符串函数
Function getByteString(StringStr)
getByteString=""
For i = 1 To Len(StringStr)
XP_varchar = mid(StringStr,i,1)
XP_varasc = Asc(XP_varchar)
If XP_varasc < 0 Then
XP_varasc = XP_varasc + 65535
End If

If XP_varasc > 255 Then
XP_varlow = Left(Hex(Asc(XP_varchar)),2)
XP_varhigh = right(Hex(Asc(XP_varchar)),2)
getByteString = getByteString & chrB("&H" & XP_varlow) & chrB("&H" & XP_varhigh)
Else
getByteString = getByteString & chrB(AscB(XP_varchar))
End If
Next
End Function

'把二进制字符串转换成普通字符串函数
Function getString(StringBin)
getString =""
Dim XP_varlen,XP_vargetstr,XP_string,XP_skip
XP_skip = 0
XP_string = ""
If Not IsNull(StringBin) Then
XP_varlen = LenB(StringBin)
For i = 1 To XP_varlen
If XP_skip = 0 Then
XP_vargetstr = MidB(StringBin,i,1)
If AscB(XP_vargetstr) > 127 Then
XP_string = XP_string & Chr(AscW(MidB(StringBin,i+1,1) & XP_vargetstr))
XP_skip = 1
Else
XP_string = XP_string & Chr(AscB(XP_vargetstr))
End If
Else
XP_skip = 0
End If
Next
End If
getString = XP_string
End Function

Function UploadFormRequest(name)
on error resume next
if UploadRequest.Item(name) then
UploadFormRequest = UploadRequest.Item(name).Item("value")
end if
End Function

'Process the upload
UploadQueryString = Replace(Request.QueryString,"GP_upload=true","")
if mid(UploadQueryString,1,1) = "&" then
    UploadQueryString = Mid(UploadQueryString,2)
end if

GP_uploadAction = CStr(Request.ServerVariables("URL")) & "?GP_upload=true"
If (Request.QueryString <> "") Then
if UploadQueryString <> "" then
     GP_uploadAction = GP_uploadAction & "&" & UploadQueryString
end if
End If

If (CStr(Request.QueryString("GP_upload")) <> "") Then
GP_redirectPage = ""
If (GP_redirectPage = "") Then
GP_redirectPage = CStr(Request.ServerVariables("URL"))
end if

RequestBin = Request.BinaryRead(Request.TotalBytes)
Dim UploadRequest
Set UploadRequest = CreateObject("Scripting.Dictionary")
BuildUploadRequest RequestBin, "images", "file", "", "over"

'*** GP NO REDIRECT
end if
if UploadQueryString <> "" then
UploadQueryString = UploadQueryString & "&GP_upload=true"
else
UploadQueryString = "GP_upload=true"
end if


%>
<%
' *** Edit Operations: declare variables

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variables

If (CStr(Request("MM_insert")) = "form1") Then

MM_editConnection = MM_t_STRING
MM_editTable = "a"
MM_editRedirectUrl = "index.asp"
MM_fieldsStr = "textarea|value|file|value"
MM_columnsStr = "t_title|',none,''|t_name1|',none,''"

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")

' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next

' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If

End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it

Dim MM_tablevalues
Dim MM_dbvalues

If (CStr(Request("MM_insert")) <> "") Then

' create the sql insert statement
MM_tablevalues = ""
MM_dbvalues = ""
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_tablevalues = MM_tablevalues & ","
MM_dbvalues = MM_dbvalues & ","
End If
MM_tablevalues = MM_tablevalues & MM_columns(MM_i)
MM_dbvalues = MM_dbvalues & MM_formVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tablevalues & ") values (" & MM_dbvalues & ")"

If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If

End If
%>



无标题文档























 
 
 
   






图片如下:

图片如下:



缺缺

职务:管理员
等级:8
金币:41.0
发贴:9620
注册:2004/1/14 19:14:47
#22003/4/21 17:40:54
第一,出了问题先看是不是自己的问题

第二,问问题说清楚到底是什么问题.贴大堆代码和两个没有什么用的图不能提供什么信息.



andy04911

职务:普通成员
等级:1
金币:0.0
发贴:64
注册:2003/2/3 23:36:05
#32003/4/21 20:01:25



whzooo

职务:普通成员
等级:1
金币:0.0
发贴:102
注册:2002/10/6 12:08:07
#42003/4/22 18:49:18
不好意思!

问题是!图片不能传上来啊!

我按照!面包的教程作的!我虽然不是高手!但应该不是我的错吧!

数据库的文件名也传不上去! 我用排除法排除过!问题在浏览文件的那个东西! 把他删了 数据库的文件名就可以插入了!



我佛山人

职务:版主
等级:4
金币:16.0
发贴:2269
注册:2002/8/7 15:09:27
#52003/4/23 13:35:31
用UD,不能用MX



xixiVSmxm

职务:普通成员
等级:1
金币:0.0
发贴:41
注册:2003/4/21 12:51:27
#62003/4/23 16:08:38
我靠! 你写的什么东西啊! 上穿插件多死了!
小正正的 和那个什么UP的都可以啊!

相关文件:点这儿打开
不过我 用的MX做的动可以的!!~~



whzooo

职务:普通成员
等级:1
金币:0.0
发贴:102
注册:2002/10/6 12:08:07
#72003/4/26 16:40:14
谁给我跟在mx下能用的上传图片的 东东!!



whzooo

职务:普通成员
等级:1
金币:0.0
发贴:102
注册:2002/10/6 12:08:07
#82003/4/26 17:25:12
谁给我个在mx下能用的中文插件阿



天丁

职务:普通成员
等级:2
金币:1.0
发贴:427
注册:2002/4/21 14:59:54
#92003/4/28 18:36:59
非用MX吗?

你就不会用UD吗?????



whzooo

职务:普通成员
等级:1
金币:0.0
发贴:102
注册:2002/10/6 12:08:07
#102003/4/29 8:15:16
...我把ud删了! 光盘也没了! 我以为mx全面向下兼容d! 软件兼容性不好会被骂的.我以为一定兼容性很好!

谁给个mx下能用的