---
title: "Chili!Upload"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/59137-chili-upload"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "Alex_net"
published: "2002-11-14T22:53:01.000Z"
updated: "2002-11-15T00:20:00.000Z"
replies: 2
views: 211
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/59137-chili-upload"
---

# Chili!Upload

## #1 — Alex_net, 2002-11-14T22:53Z

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

%\>

Permalänk: https://www.webforum.nu/p/59137

## #2 — solbulle, 2002-11-14T23:08Z

> '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?

Permalänk: https://www.webforum.nu/p/854938

## #3 — Alex_net, 2002-11-15T00:20Z

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!

Permalänk: https://www.webforum.nu/p/854985

---

Tråden på webben: https://www.webforum.nu/amne/asp/59137-chili-upload
