<%
server.ScriptTimeout = server.ScriptTimeout * 10
Dim byteDatos, strNomArch
Dim iPosInicio, iPosFin, iPos
Dim iArchIni, iArchFin
Dim oFSO, oFich
Dim i
byteDatos = Request.BinaryRead(Request.TotalBytes)
iPosInicio = 1
iPosFin = InStrB(iPosInicio, byteDatos, str2byte(chr(13)))
byteLimite = MidB(byteDatos, iPosInicio, iPosFin-iPosInicio)
posLimite = InStrB(1, byteDatos, byteLimite)
iPosInicio = InStrB(1, byteDatos, str2byte("filename=")) + 10
iPosFin = InStrB(iPosInicio, byteDatos, str2byte(chr(34)))
strNomArch = byte2str(MidB(byteDatos, iPosInicio, IposFin - iPosInicio))
iPosFin = InStrB(iPosFin, byteDatos, str2byte("Content-Type:"))
iPosFin = InStrB(iPosFin, byteDatos, str2byte(chr(13))) + 4
iArchIni = iPosFin
iArchFin = InStrB(iArchIni, byteDatos, byteLimite)-2
'IE envia el directorio de donde se encuentra el archivo
'FireFox solo envia el nombre del archivo por lo tanto
'nos aseguramos de dejar solo el nombre del archivo
strNomArch1 = ""
do while instr(1, strNomArch, "\") > 0
inicio = instr(1, strNomArch, "\") + 1
strNomArch1 = mid(strNomArch, inicio, len(strNomArch))
strNomArch = strNomArch1
loop
set oFSO = Server.CreateObject("Scripting.FileSystemObject")
set oFich = oFSO.CreateTextFile(server.MapPath("/Imagenes/Menu") & "\" & strNomArch, true)
for i = iArchIni to iArchFin
oFich.Write byte2str(MidB(byteDatos, i, 1))
next
oFich.Close
set oFSO = nothing
server.ScriptTimeout = server.ScriptTimeout / 10
'------------------------------------------------------------------------
Function str2byte ( str )
Dim i, strbuf
for i = 1 to Len(str)
strbuf = strbuf & ChrB(AscB(Mid(str, i, 1)))
next
str2byte = strbuf
End Function
'------------------------------------------------------------------------
Function byte2str ( bin )
Dim i, bytebuf
for i = 1 to LenB(bin)
bytebuf = bytebuf & Chr(AscB(MidB(bin, i, 1)))
next
byte2str = bytebuf
End Function
%>
