Solved

ASPUpload, trying to get file name after upload

Posted on 2004-08-25
7
383 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
Comment Utility
does Set Item1 = Upload.Form("FILE1")  work?
0
 
LVL 5

Expert Comment

by:darksinclair
Comment Utility
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
Comment Utility
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:polaatx
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

11 Experts available now in Live!

Get 1:1 Help Now