Upload files in asp without component, or make your own component with this script
Upload files in asp without component, or make your own component with this script
Rate Upload files in asp without component, or make your own component with this script
(2(2 Vote))
------------------------------------------------------------------------
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<img border="0" src="logoupload.gif" width="653" height="80">
<p>
<B><font face="Tahoma">Subir Una Imagen al servidor</font></b>
</p>
<FORM METHOD="Post" ENCTYPE="multipart/form-data" ACTION="upload.asp">
<b><font face="Tahoma">
Archivo a Subir </font></b> : <INPUT TYPE="file" NAME="foto">
<p> <INPUT TYPE="submit" NAME="Enter" value="Upload">
</p>
</FORM>
<hr noshade size="1" color="#000080">
<p align="center"><font face="Tahoma" size="1" color="#000080">ADULT IMAGE
SERVER </font></p>
</BODY>
</HTML>
upload.asp
-------------------------------------------------------------------------
<%
'Generate Password
on error resume next
clave = datepart("YYYY",now())& datepart("m",now())& datepart("d",now())
' -- crear directorio
destino="c:\upload\" & clave
set Fconn = server.CreateObject("scripting.FilesystemObject")
fconn.CreateFolder (destino)
set Fconn = nothing
dominio = request.servervariables("server_name")
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
'Directorio donde subir el archivo
directorio = destino
' Variables del FORM
'#############################################################
'Dim campos
'For Each campos In UploadRequest
' campex = UploadRequest.Item(""&campos&"").Item("Value")
' ResultHTML = ResultHTML & "<br>"&campos&": <b>" & campex & "</b>"
'Next
'#############################################################
contentType = UploadRequest.Item("foto").Item("ContentType")
filepathname = UploadRequest.Item("foto").Item("FileName")
'saca solo el nombre de la foto
filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
value = UploadRequest.Item("foto").Item("Value")
'Create FileSytemObject Component
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
'Create and Write to a File
Set MyFile = ScriptObject.CreateTextFile(directorio & "\" & filename)
For i = 1 to LenB(value)
MyFile.Write chr(AscB(MidB(value,i,1)))
Next
MyFile.Close
%>
<!-- #include file="l" -->
<%
if filename = "" then
else
%>
<br>
<b>Anote el link donde encuentra la imagen: </b><br><b><a href="http://s8s.com.ar/upload/<%=clave & "\" & filename%>">http://s8s.com.ar/upload/<%=clave & "/" & filename%></a> <BR>
<img src="<%=directorio& "\" &filename%>"></b><br><br>
<%=UploadRequest.Item("nombre").Item("Value")%>
<%
end if
Sub BuildUploadRequest(RequestBin)
Comienzo = 1
Final = InstrB(Comienzo,RequestBin,getByteString(chr(13)))
boundary = MidB(RequestBin,Comienzo,Final-Comienzo)
boundaryPos = InstrB(1,RequestBin,boundary)
Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--")))
Dim UploadControl
Set UploadControl = CreateObject("Scripting.Dictionary")
Pos = InstrB(BoundaryPos,RequestBin,getByteString("Content-Disposition"))
Pos = InstrB(Pos,RequestBin,getByteString("name="))
Comienzo = Pos+6
Final = InstrB(Comienzo,RequestBin,getByteString(chr(34)))
Name = getString(MidB(RequestBin,Comienzo,Final-Comienzo))
PosFile = InstrB(BoundaryPos,RequestBin,getByteString("filename="))
PosBound = InstrB(Final,RequestBin,boundary)
If PosFile<>0 AND (PosFile<PosBound) Then
'Get Filename, content-type and content of file
Comienzo = PosFile + 10
Final = InstrB(Comienzo,RequestBin,getByteString(chr(34)))
FileName = getString(MidB(RequestBin,Comienzo,Final-Comienzo))
'Add filename to dictionary object
UploadControl.Add "FileName", FileName
Pos = InstrB(Final,RequestBin,getByteString("Content-Type:"))
Comienzo = Pos+14
Final = InstrB(Comienzo,RequestBin,getByteString(chr(13)))
ContentType = getString(MidB(RequestBin,Comienzo,Final-Comienzo))
UploadControl.Add "ContentType",ContentType
Comienzo = Final+4
Final = InstrB(Comienzo,RequestBin,boundary)-2
Value = MidB(RequestBin,Comienzo,Final-Comienzo)
Else
Pos = InstrB(Pos,RequestBin,getByteString(chr(13)))
Comienzo = Pos+4
Final = InstrB(Comienzo,RequestBin,boundary)-2
Value = getString(MidB(RequestBin,Comienzo,Final-Comienzo))
End If
UploadControl.Add "Value" , Value
UploadRequest.Add name, UploadControl
BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary)
Loop
End Sub
Function getByteString(StringStr)
For i = 1 to Len(StringStr)
char = Mid(StringStr,i,1)
getByteString = getByteString & chrB(AscB(char))
Next
End Function
Function getString(StringBin)
getString =""
For intCount = 1 to LenB(StringBin)
getString = getString & chr(AscB(MidB(StringBin,intCount,1)))
Next
End Function
%>
Upload files in asp without component, or make your own component with this script Comments
No comments yet — be the first to post one!
Post a Comment