Tach
tach auch!
Ich such schon lange nach einer Lösung, wie man mit ASP (ohne zusätzliche Komponenten) einen Datei Upload (from Client to Server) hinkriegt. Da es einmal im Selfhtml einen Artikel darüber gegeben hat, sollte das ja Dokumentiert sein. Also, falls jemand noch etwas darüber weiss, soll er sich bitte melden.
schau das mal an...
Danke
<%
Response.Expires = 0
Response.Buffer = true
Server.ScriptTimeOut = 300
laenge = Request.TotalBytes
maxsize = 150000
uploadfolder = Server.MapPath(Request.ServerVariables("URL"))
uploadfolder = Replace(Left(uploadfolder,len(uploadfolder)-(len(uploadfolder)-InstrRev(uploadfolder,"")+1)),"update","Ueberbauungen",1,-1,1) & "\images" & Session("ub_name")
if laenge > 0 then
ProcessUpload
else
DoRedirect
end if
sub DoRedirect
Response.Redirect "edit_pics_ueberbauung.asp?ID=" & Session("ub_id") & ""
end sub
sub ProcessUpload
if laenge > maxsize then
muell = Request.BinaryRead(laenge)
else
set util = Server.CreateObject("ixsso.Util")
rawpost = ""
for x=1 to laenge
bytedata = (util.GetArrayElement(Request.BinaryRead(1),0))
rawpost = rawpost + chr(bytedata)
next
set util = Nothing
findstart = InStr(rawpost, vbCrLf & vbCrLf)
if findstart>0 then
rawfiledata = mid(rawpost, findstart+4)
headerdata = left(rawpost, findstart)
delimiter = left(headerdata, 40)
startpos = InstrRev(headerdata, "filename=")
startpos = Instr(startpos, headerdata, """")
endpos = Instr(startpos+1, headerdata, """")
filename = mid(headerdata, startpos+1, endpos-startpos-1)
if filename = "" then
DoRedirect
end if
startpos = Instr(rawfiledata, delimiter)
rawfiledata = left(rawfiledata, startpos-3)
set fs = Server.CreateObject("Scripting.FileSystemObject")
if not right(uploadfolder,1)="" then
uploadfolder = uploadfolder + ""
end if
fileownname = fs.GetFileName(filename)
if not fs.FolderExists(uploadfolder) then
DoRedirect
end if
set fh = fs.CreateTextFile(uploadfolder & fileownname, vbTrue)
fh.Write rawfiledata
fh.close
set fh = Nothing
set fs = Nothing
DoRedirect
end if
end if
end sub
%>