Subject: ASP Upload - does object persist across pages?
Posted By: James Diamond Post Date: 1/27/2004 6:49:26 AM
Hi,

I am using the ASPUpload component.

I declare a global variable "Upload" in an ASP include file.

Then, I create an instance on my first page (that includes the include file):

Set Upload = Server.CreateObject("Persits.Upload")

and upload my pics to memory:

numPicsUploaded = Upload.Save

then save them as new names to a temporary directory on the server, which works fine.

I then redirect from this page to an ASP page that previews the uploaded pics.

Question: On this new page, can I reference the Upload object? It seems that I can't. However, I need to, because I want to manipulate the uploaded files (move them from the temporary directory to my main picture directory, and delete them from the temporary directory) at that point.

Does the Upload object persist on the server so that all pages can use it after it has been created? If so, for how long does it exist, and how would I destroy it? Is there a "destructor" for it?

Hope you can help.

Thanks.

James

//##




Reply By: Imar Reply Date: 1/27/2004 7:04:31 AM
Hi there,

Nope, the Upload object goes out of scope (is destroyed) as soon as the page has finished loading. When you redirect to another page, there is no way to access the Upload object again.

What you can do is pass the name / location / ID / something else unique about the file to the next page. On that page, retrieve the location and name of the file (based on the unique characteristic) and create new objects that allow you to manipulate your file.

Does this help?

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply By: James Diamond Reply Date: 1/27/2004 7:24:59 AM
Imar,

Thanks - that helps.

Do I create another Upload object on the new page in order to "get hold of" the saved file again (using its unique name etc)?

How do I do this? Which methods do I use to do it?

James

Reply By: James Diamond Reply Date: 1/27/2004 7:31:35 AM
I suppose like this...

http://www.aspupload.com/object_upload.html#MoveFile

:)

Reply By: Imar Reply Date: 1/27/2004 8:41:56 AM
That's one way to do it.

You can also take a look at the Microsoft FileSystemObject. It allows you to copy, move and delete files and folders, among other things.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/FSOoriFileSystemObject.asp?frame=true

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.

Go to topic 8785

Return to index page 961
Return to index page 960
Return to index page 959
Return to index page 958
Return to index page 957
Return to index page 956
Return to index page 955
Return to index page 954
Return to index page 953
Return to index page 952