UPLOAD SIN COMPONENTES (para el que le interese)
Publicado por fer (270 intervenciones) el 23/08/2001 13:23:19
Excelente articulo de MIquel van Otegem de alliance para el que quiera comprender el funcionamiento de clases en ASP y como se suben ficheros al servidor.
uploadscript1.asp
<%
Option Explicit
Dim oUpload
'Create object, note the New statement instead of Server.CreateObject
Set oUpload = New FileUpload
'Read and set MIME type and then send file back to browser
Response.ContentType = oUpload.ContentType("UploadFile")
Response.BinaryWrite oUpload.Value("UploadFile")
Set oUpload = Nothing
%>
<!--#include file="clsFileUpload.asp"-->
You can also request the values in the form and save the file.
uploadscript2.asp
<%
Option Explicit
Dim oUpload
Dim oFSO, oFile
Dim lngPathEnd
Dim strPath, strFile
Dim i
'Create object, note the New statement instead of Server.CreateObject
Set oUpload = New FileUpload
'Get path and filename
lngPathEnd = Len(Server.MapPath(Request.ServerVariables("PATH_INFO"))) - 14
strPath = Left(Server.Mappath(Request.ServerVariables("PATH_INFO")), lngPathEnd)
strFile = "uploaded" & oUpload.FileName("UploadFile")
'Create file and write data into it
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.CreateTextFile(strPath & strFile)
For i = 1 To LenB(oUpload.Value("UploadFile"))
oFile.Write Chr(AscB(MidB(oUpload.Value("UploadFile"), i, 1)))
Next
'Close file and release objects
oFile.Close
Set oFile = Nothing
Set oFSO = Nothing
Response.Write "Thank yo
uploadscript1.asp
<%
Option Explicit
Dim oUpload
'Create object, note the New statement instead of Server.CreateObject
Set oUpload = New FileUpload
'Read and set MIME type and then send file back to browser
Response.ContentType = oUpload.ContentType("UploadFile")
Response.BinaryWrite oUpload.Value("UploadFile")
Set oUpload = Nothing
%>
<!--#include file="clsFileUpload.asp"-->
You can also request the values in the form and save the file.
uploadscript2.asp
<%
Option Explicit
Dim oUpload
Dim oFSO, oFile
Dim lngPathEnd
Dim strPath, strFile
Dim i
'Create object, note the New statement instead of Server.CreateObject
Set oUpload = New FileUpload
'Get path and filename
lngPathEnd = Len(Server.MapPath(Request.ServerVariables("PATH_INFO"))) - 14
strPath = Left(Server.Mappath(Request.ServerVariables("PATH_INFO")), lngPathEnd)
strFile = "uploaded" & oUpload.FileName("UploadFile")
'Create file and write data into it
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.CreateTextFile(strPath & strFile)
For i = 1 To LenB(oUpload.Value("UploadFile"))
oFile.Write Chr(AscB(MidB(oUpload.Value("UploadFile"), i, 1)))
Next
'Close file and release objects
oFile.Close
Set oFile = Nothing
Set oFSO = Nothing
Response.Write "Thank yo
Valora esta pregunta


0