RESPUESTA A LA PREGUNTA 11596 - ASP 1)En un archivo, por ejemplo (llamalo upload.asp) copia lo siguiente: <% ' Author Philippe Collignon ' Email PhCollignon@email.com Sub BuildUploadRequest(RequestBin) 'Get the boundary PosBeg = 1 PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13))) 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 2)Luego, en otro archivo (llamalo outputFile.asp)puedes copiar : <% ' Author Philippe Collignon ' Email PhCollignon@email.com Response.Expires=0 Response.Buffer = TRUE Response.Clear 'Response.BinaryWrite(Request.BinaryRead(Request.TotalBytes)) byteCount = Request.TotalBytes 'Response.BinaryWrite(Request.BinaryRead(varByteCount)) RequestBin = Request.BinaryRead(byteCount) Dim UploadRequest Set UploadRequest = CreateObject("Scripting.Dictionary") BuildUploadRequest RequestBin email = UploadRequest.Item("email").Item("Value") contentType = UploadRequest.Item("blob").Item("ContentType") filepathname = UploadRequest.Item("blob").Item("FileName") filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\")) value = UploadRequest.Item("blob").Item("Value") 'Create FileSytemObject Component Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject") 'Create and Write to a File pathEnd = Len(Server.mappath(Request.ServerVariables("PATH_INFO")))-14 Set MyFile = ScriptObject.CreateTextFile(Left(Server.mappath(Request.ServerVariables("PATH_INFO")),pathEnd)&"uploaded"&filename) For i = 1 to LenB(value) MyFile.Write chr(AscB(MidB(value,i,1))) Next MyFile.Close %> Uploaded file : <%="uploaded"&filename%>
"> 3)En otro Archivo (llamalo binaryOutputClient.asp) copia lo siguiente: <% ' Author Philippe Collignon ' Email PhCollignon@email.com Response.Buffer = TRUE Response.Clear byteCount = Request.TotalBytes RequestBin = Request.BinaryRead(byteCount) Dim UploadRequest Set UploadRequest = CreateObject("Scripting.Dictionary") BuildUploadRequest RequestBin email = UploadRequest.Item("email").Item("Value") contentType = UploadRequest.Item("blob").Item("ContentType") filepathname = UploadRequest.Item("blob").Item("FileName") filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\")) picture = UploadRequest.Item("blob").Item("Value") Response.ContentType = contentType Response.binaryWrite picture %> 4)En otro archivo (llamalo outputClient.asp) copia lo sioguiente: <% ' Author Philippe Collignon ' Email PhCollignon@email.com Response.Buffer = TRUE Response.Clear byteCount = Request.TotalBytes RequestBin = Request.BinaryRead(byteCount) Dim UploadRequest Set UploadRequest = CreateObject("Scripting.Dictionary") BuildUploadRequest RequestBin email = UploadRequest.Item("email").Item("Value") contentType = UploadRequest.Item("blob").Item("ContentType") filepathname = UploadRequest.Item("blob").Item("FileName") filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\")) value = UploadRequest.Item("blob").Item("Value") %> Your email is : <%= email %>
File name of you picture is <%=filepathname%>
File type of your picture is <%=contentType%>
5)Copia el .HTML de donde correras las .asp anteriores del ejemplo para ilustrarte como funciona, llama a este .html uploadForm.htm : Upload Form Output to client
Email :
Picture :
Binary output to client
Email :
Picture :
Output to file system
Email :
Picture :
6)La manera como lo hace es que manipula el stream de caracteres que la pagina envia al servidor al hacer un submit. considerando que siempre cuando haces un submit, envias tambien las imagenes en el stream(rio) de caracteres. Luis Fernando Martinez lmartine@telconet.net