Solved

ASPUpload, trying to get file name after upload

Posted on 2004-08-25
7
391 Views
Last Modified: 2008-02-26
Hi, I am trying to get the name of the name of the file that ASPUpload just uploaded and set it to a variable to be used elsewhere in the page.  I've read material in ASPUpload site and also here: http://www.asp101.com/resources/aspupload.asp

 Set myfile = Upload.Files("FILE1") should work, but it doesn't. Here's my code right now:


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

      Upload.OverwriteFiles = False
      On Error Resume Next

      Upload.SetMaxSize 1048576      ' Limit files to 1MB
      Count = Upload.Save("\\premfs14\sites\premium14\aasg\webroot\aura\images\faculty")

Set myfile = Upload.Files("FILE1")
0
Comment
Question by:polaatx
  • 4
  • 3
7 Comments
 
LVL 5

Expert Comment

by:darksinclair
ID: 11896971
does Set Item1 = Upload.Form("FILE1")  work?
0
 
LVL 5

Expert Comment

by:darksinclair
ID: 11896987
what do you get when u run the following examples off the site?

<%  
Set Upload = Server.CreateObject("Persits.Upload.1")  
Upload.Save "c:\upload"
%>  
Files:<BR>  
<%  
For Each File in Upload.Files  
Response.Write File.Name & "=" & File.Path & " (" & File.Size & ")<BR>"
Next
%>  
<P>  
Other items:<BR>  
<%  
For Each Item in Upload.Form  
Response.Write Item.Name & "=" & Item.Value & "<BR>"
Next
%>  

Cheers,
0
 

Author Comment

by:polaatx
ID: 11897061
Set Item1 = Upload.Form("FILE1") doesn't work.

The code you site above runs fine. I do get everything printed out correctly. The problem is that File.Name works only after it appears "For Each File in Upload.Files"

I need to get the File.Name way before it gets to html because I need to attach the file to an email.

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:polaatx
ID: 11898963
Gosh, I am still working on this. I've read much of the aspUpload's manual and from all I can tell this should work:

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

      Upload.OverwriteFiles = False
      On Error Resume Next

      Upload.SetMaxSize 1048576      ' Limit files to 1MB
      Count = Upload.Save("\\premfs14\sites\premium14\aasg\webroot\aura\images\faculty")

                 Set Item1 = Upload.Files("FILE1")

But when I put  File Name = <%=Item1%> in the html, I get nothing. The photo uploads, but I don't get the damn file name. So I can't attach it to an email. It's driving me nuts!

Any help would be much appreciated.

0
 
LVL 5

Accepted Solution

by:
darksinclair earned 500 total points
ID: 11902287
wouldn't from their example you need File Name = <%=Item1.Name%> ? as you are making Item1 a File Object?

-> their example seems horrible, I looked at it but I didnt' like it.
0
 

Author Comment

by:polaatx
ID: 11908138
I agree. Many of their examples are really confusing. They actually answer their email though.
I heard back and this is how to do it:

<%
      Set Upload = Server.CreateObject("Persits.Upload.1")

      Upload.Save ("\\premfs14\sites\premium14\aasg\webroot\aura\images\faculty\")

'Set item1 = Upload.Files(1)  %>

item1 then becomes the variable that contains the file name.
0
 
LVL 5

Expert Comment

by:darksinclair
ID: 11908896
well Im glad atleast they support their customers.  Glad you were able to get this figured out dude and thanks for the points.

Take care and happy coding

Cheers,
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now