Foros del Web » Programando para Internet » ASP Clásico »

Como ingreso una variable de session?

Estas en el tema de Como ingreso una variable de session? en el foro de ASP Clásico en Foros del Web. Disculpen pero no logro colocar una variable de session ("login") en el path de este script. El path me deposita el archivo subido en la ...
  #1 (permalink)  
Antiguo 27/12/2007, 14:40
Avatar de JJF
JJF
 
Fecha de Ingreso: mayo-2005
Mensajes: 205
Antigüedad: 19 años
Puntos: 0
Sonrisa Como ingreso una variable de session?

Disculpen pero no logro colocar una variable de session ("login") en el path de este script.

El path me deposita el archivo subido en la carpeta raiz y lo que quiero es que la suba a la carpeta del usuario y el nombre de esa carpeta es el mismo que el login.

este es el code:

<%@ Language="VBScript" %>
<!--#include file="_cls2020Upload.asp"-->
<%
dim t1,t2
t1 = Timer()
' TIP: Delete all the comments to see the code
' flow more clearly.

' Define a variable to store the clsUpload object.
dim objUpload

' Instantiate the clsUpload object.
set objUpload = New clsUpload

' Turn on file extensions restriction.
objUpload.RestrictFileExtentions = True

' Set a list of known "safe" file extensions.
objUpload.SafeFileExtensions = "png|jpg|gif|bmp"

' Call the Upload() method to retrieve data from
' the HTTP header. Prepare for failure.
' Just as example, I've set the path to "" in this
' case. You could set the folder path here, or as
' in this example you can set the folder path for
' each file.
' (look for the objFile.UploadPath stuff later).
IF NOT objUpload.Upload("") THEN
%>
<p><%=err.Number &": "& err.Description%>
<%
END IF

' As a courtesy, I'll write some data to the page.
' Note that Windows Server 2003 imposed a 200 kilobyte size restriction
' on HTTP headers called "AspMaxRequestEntityAllowed"
' This is documented here: http://msdn.microsoft.com/library/de...86e2b3e9e2.asp
response.write("<p>Total Bytes Uploaded: "& objUpload.TotalBytes &"</p>")

' Check if some files exists in the HTTP header.
IF objUpload.Files.Count = 0 THEN
%>
<p>No files were uploaded or no files have &quot;Safe&quot; file extensions.</p>
<%
' If there are files, then let's proceed.
ELSE

' Create variables for later use.
dim item
dim objFile
dim strFileName
dim strFileExtension

' Loop through the file objects.
FOR EACH item IN objUpload.Files

' Set the objFile variable to a reference to this item in the Files collection.
set objFile = objUpload.Files(item)

' Check to see that the folder exists. (We can do this before "saving" the file.)
IF NOT objFile.FolderExists THEN
%>
<p>Folder doesn't exist. Will reset the folder to:
<%
' In this example, I KNEW that the folder wouldn't exist, so I'll reset that
' property here.
objFile.UploadPath = Replace(server.MapPath(request.servervariables("SC RIPT_NAME")),Mid(request.servervariables("SCRIPT_N AME"),2),"")
' I've reset the "UploadPath" property, so now I'll explicitly call the
' "BuildPath()" method just as a courtesy.
objFile.BuildPath
%><%=objFile.UploadPath%></p>
<%
END IF

' Let's grab the file name.
strFileName = objFile.FileName

' And write more stats to the page.
response.write("<p>File: "& strFileName &"<br />Size: "& objFile.Size &"<br />Content-Type:"& objFile.ContentType)

' We can check to see if this is a duplicate file name.
IF objFile.FileExists THEN
' Grab the file extension.
strFileExtension = LCase(Right(strFileName,Len(strFileName) - InStrRev(strFileName,".")))
' Make a new file name.
strFileName = objFile.Size &"-"& Replace(CDbl(Now()),".","") &"."& strFileExtension
' Reset the file name.
objFile.FileName = strFileName
' More stats.
response.write("<br />File Already Exists. Name changed to: "& strFileName)
END IF

' Now "Save" the file. (Prepare for failure.)
IF NOT objFile.Save THEN
%>
<p>Cannot save file.</p>
<%
ELSE
' Great!
%>
<p>File Uploaded and Saved to <%=objFile.UploadPath%></p>
<%
END IF

response.write("</p>")

' Cleanup the file object.
set objFile = nothing

NEXT

END IF

' Check if some form elementss exist in the HTTP header.
IF objUpload.Form.Count = 0 THEN
%>
<p>No form elements exist.</p>
<%
' If so, then let's just write them to the page.
ELSE

' Create a variable to store the dictionary item.
dim element

' Then loop through them and write them to the page.
FOR EACH element IN objUpload.Form
%>
<p>Name: <%=element%><br />Value: <%=objUpload.Form(element)%></p>
<%
NEXT

END IF

' Cleanup
set objUpload = nothing

t2 = Timer()
response.write("Time: "& t2-t1)
%>



Muchas gracias, muy amables y disculpen que ponga todo completito. es que lo quiero entender bien
Saludos
  #2 (permalink)  
Antiguo 28/12/2007, 11:25
Avatar de Shiryu_Libra
Colaborador
 
Fecha de Ingreso: febrero-2007
Ubicación: Cantando "Screenager" en "Kirafa Kaput"
Mensajes: 3.614
Antigüedad: 17 años, 3 meses
Puntos: 88
Re: Como ingreso una variable de session?


en esta parte, que directorio te asigna??
Cita:
IF NOT objFile.FolderExists THEN
%>
<p>Folder doesn't exist. Will reset the folder to:
<%
' In this example, I KNEW that the folder wouldn't exist, so I'll reset that
' property here.
objFile.UploadPath = Replace(server.MapPath(request.servervariables("SC RIPT_NAME")),Mid(request.servervariables("SCRIPT_N AME"),2),"")
' I've reset the "UploadPath" property, so now I'll explicitly call the
' "BuildPath()" method just as a courtesy.
objFile.BuildPath
%><%=objFile.UploadPath%></p>
<%
END IF
por no miro que le asignes ningun directorio en especifico, se denota que sera en la direccion

http://www.tudominio.com/sitio/pagina.asp

pero no esta incluida la direccion de la carpeta en especifica que deseas
__________________
"Eres parte del problema, parte de la solucion o parte del paisaje"
Un Saludo desde Desierto de Altar, Sonora, MX.
Shiryu_libra
  #3 (permalink)  
Antiguo 28/12/2007, 11:50
Avatar de JJF
JJF
 
Fecha de Ingreso: mayo-2005
Mensajes: 205
Antigüedad: 19 años
Puntos: 0
Sonrisa Re: Como ingreso una variable de session?

Gracias por responder.
Específicamente en qué linea? porque me carga el fichero en la carpeta raiz.

la ruta es:

C:\WEBSITES\HOST\juanjoquerido\micoche.com.ar\web\

Después de \web\ quiero que aparezca la variable ejemplo....

C:\WEBSITES\HOST\juanjoquerido\micoche.com.ar\web\ ("&variable&")
  #4 (permalink)  
Antiguo 28/12/2007, 12:25
Avatar de Shiryu_Libra
Colaborador
 
Fecha de Ingreso: febrero-2007
Ubicación: Cantando "Screenager" en "Kirafa Kaput"
Mensajes: 3.614
Antigüedad: 17 años, 3 meses
Puntos: 88
Re: Como ingreso una variable de session?

ok, entonces podria ser de esta manera

Cita:
path=server.mappath("./")
path=path & session("idusuario") & "/"
algo asi
Cita:
IF NOT objFile.FolderExists THEN%>
<p>Folder doesn't exist. Will reset the folder to: <%
' In this example, I KNEW that the folder wouldn't exist, so I'll reset that
' property here.

destino = server.mappath("./")
destino = destino & session("idusuario") & "/"

objFile.UploadPath = destino
objFile.BuildPath

response.write objFile.UploadPath%></p><%
END IF
haz una prueba, haber que pasa
__________________
"Eres parte del problema, parte de la solucion o parte del paisaje"
Un Saludo desde Desierto de Altar, Sonora, MX.
Shiryu_libra
  #5 (permalink)  
Antiguo 28/12/2007, 12:52
Avatar de JJF
JJF
 
Fecha de Ingreso: mayo-2005
Mensajes: 205
Antigüedad: 19 años
Puntos: 0
De acuerdo Re: Como ingreso una variable de session?

Muchas gracias!! Voy a probar!
  #6 (permalink)  
Antiguo 28/12/2007, 13:42
Avatar de JJF
JJF
 
Fecha de Ingreso: mayo-2005
Mensajes: 205
Antigüedad: 19 años
Puntos: 0
Sonrisa Re: Como ingreso una variable de session?

le tuve que agregar un &/& y listo! Porque sino me pegaba el destino a la variable

destino = server.mappath("./")
destino = destino & "/" & session("login") & "/"

objFile.UploadPath = destino
objFile.BuildPath

response.write objFile.UploadPath%></p>

Muchas Gracias! Fuiste muy amable y de mucha ayuda
Abrazos desde Argentina!!
  #7 (permalink)  
Antiguo 28/12/2007, 14:16
Avatar de Shiryu_Libra
Colaborador
 
Fecha de Ingreso: febrero-2007
Ubicación: Cantando "Screenager" en "Kirafa Kaput"
Mensajes: 3.614
Antigüedad: 17 años, 3 meses
Puntos: 88
Re: Como ingreso una variable de session?

perfecto, Saludos
__________________
"Eres parte del problema, parte de la solucion o parte del paisaje"
Un Saludo desde Desierto de Altar, Sonora, MX.
Shiryu_libra
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 21:31.