Wrox Programmer Forums
|
Classic ASP Components Discussions specific to components in ASP 3.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Components section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 27th, 2004, 07:49 AM
Authorized User
 
Join Date: Jan 2004
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP Upload - does object persist across pages?

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

//##




 
Old January 27th, 2004, 08:04 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.
 
Old January 27th, 2004, 08:24 AM
Authorized User
 
Join Date: Jan 2004
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old January 27th, 2004, 08:31 AM
Authorized User
 
Join Date: Jan 2004
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I suppose like this...

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

:)

 
Old January 27th, 2004, 09:41 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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/de...asp?frame=true

Cheers,

Imar


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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Best way to persist Context.User across pages? musa BOOK: ASP.NET Website Programming Problem-Design-Solution 5 January 4th, 2008 12:07 AM
Client(javascript) from asp:button wont persist VictorVictor ASP.NET 2.0 Professional 35 February 27th, 2007 03:40 PM
upload problem with asp pages bailemad Classic ASP Professional 1 November 21st, 2006 09:52 AM
how to upload asp pages to web 222 Classic ASP Basics 1 June 10th, 2003 02:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.