webForumDet fria alternativet

Chili!Upload

ASP

2 svar · 207 visningar · startad av Alex_net

Medlem sedan okt. 200225 inlägg
Frågan#1

Har problem med "session variable" här stor att man kan hämta
den och använda på andra sidor tex i formulär och sen spara db.
-----------------------------------------------------------------------------------
"this session variable has a lifetime as that of the session and it will be used by other ASP pages"
-----------------------------------------------------------------------------------

Måste säga att vet ej vilken variabel ska jag hämta, här är komplet kod (annars allt annat funkar bra).
Tack!

<!-- #include file="lib.asp" -->

<%
' fattach.asp is an action page and it doesn’t generate HTML output
' It handles the response from fileattach.asp.
' Using the FileSystem object it creates a temporary directory to place attached files into if it doesn't exist.
' Then using Chili!Upload component uploads the file into that directory
' It also saves the name of this file and its temporary location in the array witch will be copied in to session variable
' this session variable has a lifetime as that of the session and it will be used by other ASP pages.

'page doesn't expier
Response.Expires = 0

'get the number of attached files
nFAtt = Session("NumFilesAttached")

If not nFAtt > 0 then

  'no files attached
  nFAtt = 0

  'create array to keep file names and directories
  Dim arFilesAttached(5,2)

else

  'get the array with the attached files inforamtion from the session variable
  arFilesAttached = Session("arFilesAttached")

end if

'Create Chili!Upload component
Set fbase = Server.CreateObject("chili.upload.1")

'Set the maximum size of the file that can be uploaded
fbase.SizeLimit = 1000000

Set oFS = Server.CreateObject("Scripting.FileSystemObject")

'Check the operating system to set the correct slash for the path
strSlash = GetSlash()

'gets the physical path to the application
strPath = GetPath(Request.ServerVariables("PATH_TRANSLATED"),strSlash)

'sets the temporary path
strPath = strPath & strSlash & "tmp"

'replace double slashes with single one
strPath = Replace(strPath,strSlash & strSlash, strSlash)

'checks is the temporary path exists
If not oFS.FolderExists (strPath) then

  'creates temporary path
  oFS.CreateFolder strPath

end if

'Report an error if the file name is empty or the the size is zero
on error resume next

strFileName = fbase.SourceFileName
if Err.number<>0 then

  Session("msg") = "\<font color=""red""\>" & Err.description & ".\</font\>"

  Response.Redirect "message.asp" 

end if
on error goto 0

if fbase.FileSize=0 then
Session("msg") = "<font color=""red"">File has zero length or it doesn't exist.</font>"
Response.Redirect "message.asp"
end if

'gets the file name from the path
If InStr(strFileName, "/") Then

  strFName = GetFileName (strFileName,"/")

else

  strFName = GetFileName (strFileName,"\\")

end if

'create temporary folder to save the file
strTmpFolder = strPath & strSlash & oFS.GetTempName
oFS.CreateFolder( strTmpFolder )

'compose the temp path and file name
strTmpPath = strTmpFolder & strSlash & strFName
'strTmpPath = strPath & strSlash & strFName

'saves the uploaded file to the temp file
fbase.SaveToFile strTmpPath

Set fbase = nothing

'seeks empty element in the temporary array
i=0
Do While i < nFAtt and not IsEmpty(arFilesAttached(i, 0)) and not arFilesAttached(i, 0)=""
i = i + 1
Loop

'check if it exeeds the array boundaries
if i+1 > UBound(arFilesAttached) then

  'expands the array
  ReDim Preserve arFilesAttached(UBound(arFilesAttached)+5) 

end if

'keep the file name ad directory in the array
arFilesAttached(i, 0) = strFName

arFilesAttached(i, 1) = strTmpFolder

if i = nFAtt then

  nFAtt = nFAtt + 1

end if

'save the array with attahced file names and paths into server variable
Session("arFilesAttached") = arFilesAttached

'keep the files count into server variable
Session("NumFilesAttached") = nFAtt

Response.Redirect "upload.asp"
'end of the asp page

%>

Medlem sedan mars 20015 287 inlägg
#2

'save the array with attahced file names and paths into server variable
Session("arFilesAttached") = arFilesAttached

Session("arFilesAttached") innehåller väl en array med filnamn samt sökväg vad jag kan förstå.

Vad ska du göra med värdena?

Medlem sedan okt. 200225 inlägg
#3

Det har jag testat med <%=Session("arFilesAttached")%>
och får meddelande

error '80004005'
/chiliupload/1.asp, line 8

Jag vill lada bilder, sen hämta värde i en annan form som ska man kunna spara sen i db.

värde = sökväg till temp katalogen och namn på laddade bild(som text).

Sen ska man kunna fylla i också andra fälten i formuläret (tex. namn, rubrik....osv) och spara alt i access databas.

Det här är ett annonserings system där ska man kunna annonsera samt lada bilder, kan inte lösa detta problem med den Chilli grejen...

I två veckor försöker lösa men de går inte och webbhotellet ger mig inte någon annan alternativ....vet ej ???

Jag blir jätte tacksam om du kan hjälpa mig!

278 ms totalt · 4 externa anrop · v20260731065814-full.6fe65c25
135 ms — deklarationer (db)
0 ms — hämta statistik (cache)
132 ms — hämta tråd, inlägg och bilagor (db)
143 ms — ändringar (db)