Multi upload ?
Kik lidt på nedenstående !kan man ikke få den til at acceptere <input type="text"> i stedet for <input type="file"> ?
<% @EnableSessionState = False %>
<% Option Explicit %>
<% Response.Expires = 0 %>
<%
Dim UPLOAD_PATH
UPLOAD_PATH = Server.MapPath("/fotos")
response.write UPLOAD_PATH&"<br>"
Dim g_oFso, g_oFolder, g_oFile
Set g_oFso = Server.CreateObject("Scripting.FileSystemObject")
Set g_oFolder = g_oFso.getFolder(UPLOAD_PATH)
If (Request.ServerVariables("REQUEST_METHOD") = "POST") Then
Dim g_oUpload
Dim fpos, fcontent, taller,minlinje,i
Set g_oUpload = get_upload_files()
For taller = 1 to 5
fcontent = g_oUpload("linie"&taller).Item("content")
if fcontent <> "" then
Set g_oFile = g_oFso.CreateTextFile(UPLOAD_PATH & "\" & extract_filename(g_oUpload("linie"&taller).Item("filename")))
For fpos = 1 to LenB(fcontent)
g_oFile.Write chr(AscB(MidB(fcontent, fpos, 1)))
Next
g_oFile.Close: Set g_oFile = Nothing
end if
Next
'response.write("<html><body bgcolor=silver><center>Filen er uploaded korrekt!</center></body></html>") 'denne linie skal ændres hvis det skal ændres... Eller der skal mere til..
response.end
Response.Redirect Request.ServerVariables("SCRIPT_NAME")
End If
Response.Write "<html><body bgcolor=silver><center>"
Response.Write "<form name=""frmUpload"" method=""post"" enctype=""multipart/form-data"" action=""" & Request.ServerVariables("SCRIPT_NAME") & """>"
' Problemet er at de skal være af typen FILE
Response.Write "<input type=""file"" style=width:400 name=""linie1"" value=""C:\Documents and Settings\larsen\Dokumenter\Billeder\cbx650-1.jpg""><br>"
Response.Write "<input type=""file"" style=width:400 name=""linie2"" value=""C:\Documents and Settings\larsen\Dokumenter\Billeder\cbx650-2.jpg""><br>"
Response.Write "<input type=""file"" style=width:400 name=""linie3"" value=""C:\Documents and Settings\larsen\Dokumenter\Billeder\cbxside400.jpg""><br>"
Response.Write "<input type=""file"" style=width:400 name=""linie4"" value=""""><br>"
Response.Write "<input type=""file"" style=width:400 name=""linie5"" value=""""><br>"
Response.Write "<input type=""submit"" value=""Upload"" style=width:100></form>"
Response.Write "</center></body></html>"
%>
<%
Function get_upload_files()
Dim upload_object, request_binaries
Dim position_start, position_end
Dim boundary, boundary_pos
Set upload_object = Server.CreateObject("Scripting.Dictionary")
request_binaries = Request.BinaryRead(Request.TotalBytes)
position_start = 1
position_end = InstrB(position_start, request_binaries, get_byte_string(chr(13)))
boundary = MidB(request_binaries, position_start, (position_end - position_start))
boundary_pos = InstrB(1, request_binaries, boundary)
Do Until (boundary_pos = InstrB(request_binaries, boundary & get_byte_string("--")))
If Not(Response.IsClientConnected) Then Response.End
Dim name, pos_file
position_start = (InstrB(InstrB(boundary_pos, request_binaries, get_byte_string("Content-Disposition")), request_binaries, get_byte_string("name=")) + 6)
position_end = InstrB(position_start, request_binaries, get_byte_string(chr(34)))
name = get_string(MidB(request_binaries, position_start, (position_end - position_start)))
pos_file = InstrB(boundary_pos, request_binaries, get_byte_string("filename="))
If ((pos_file <> 0) AND (pos_file < InstrB(position_end, request_binaries, boundary))) Then
upload_object.Add name, Server.CreateObject("Scripting.Dictionary")
position_start = (pos_file + 10)
position_end = InstrB(position_start, request_binaries, get_byte_string(chr(34)))
upload_object.item(name).Add "filename", get_string(MidB(request_binaries, position_start, (position_end - position_start)))
position_start = (InstrB(position_end, request_binaries, get_byte_string("Content-Type:")) + 14)
position_end = InstrB(position_start, request_binaries, get_byte_string(chr(13)))
upload_object.item(name).Add "content-type", get_string(MidB(request_binaries, position_start, (position_end - position_start)))
position_start = (position_end + 4)
position_end = InstrB(position_start, request_binaries, boundary) - 2
upload_object.item(name).Add "size", ((position_end - position_start))
upload_object.item(name).Add "content", MidB(request_binaries, position_start, (position_end - position_start))
End If
boundary_pos = InstrB(boundary_pos + LenB(boundary), request_binaries, boundary)
Loop
Set get_upload_files = upload_object
End Function
Function get_byte_string(str)
Dim cnt
For cnt = 1 to Len(str)
get_byte_string = get_byte_string & chrB(AscB(Mid(str, cnt, 1)))
Next
End Function
Function get_string(str)
Dim cnt
For cnt = 1 to LenB(str)
get_string = get_string & chr(AscB(MidB(str, cnt, 1)))
Next
End Function
Function extract_filename(filename)
extract_filename = Right(filename, Len(filename) - InStrRev(filename, "\", -1, 1))
End Function
%>