Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 26th, 2004, 01:51 AM
Authorized User
 
Join Date: Jun 2003
Location: Melbourne, Victoria, Australia.
Posts: 90
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to tdaustin Send a message via Yahoo to tdaustin
Default Getting FieldName in a form

Hi all,

Im doing a multiple upload with aspSmartUpload. I loop through the file elements. One of the form elements i want to put in one folder and the others in another folder.

To do this in need to get the fieldname of the current file upload, so i can do a condition when saving the file.

Code:
 For each file In mySmartUpload.Files
   '  Only if the file exist
   '  **********************
      If not file.IsMissing Then

      'Generate Random file name
      dim max,min
      max=99999999
      min=00000001
      RanFileName = (Int((max-min+1)*Rnd+min))
      ' Add extension
      FileExt = "." & file.FileExt
      ' Merge Random File Name and extention
      FileName = RanFileName & FileExt
      If *FieldName here...* = "OppImage" Then
         file.SaveAs("/gameslink/uploads/" & FileName)
      Else
           file.SaveAs("/gameslink/files/" & FileName)
      End If
         Response.Write "File Uploaded: " & FileName & "<BR>"
End If
Next
Thanks for your help

Tim

TDA
__________________
TDA
Reply With Quote
  #2 (permalink)  
Old July 26th, 2004, 06:25 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

How many other fieldnames you have? Is that so, you have many fieldnames all filled with filenames and do get uploaded using aspsmartupload?

Can you explain more on that?

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
  #3 (permalink)  
Old July 26th, 2004, 06:55 PM
Authorized User
 
Join Date: Jun 2003
Location: Melbourne, Victoria, Australia.
Posts: 90
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to tdaustin Send a message via Yahoo to tdaustin
Default

I have 5 file fields in the form previously

OppImage
OppFile1
OppFile2
OppFile3
OppFile4

I need to put the OppImage into a directory called 'uploads' and the other 4 files into a directory called 'files'

I would like to do this by checking the fieldname of the current file being uploaded.(using aspSmartUpload) then asigning it to the right directory.

I have found a solution by using a counter in my For Loop because i know the first file in the form is the OppImage. But this solution i have done would not be applicable for dynamic forms and cause a problem if somehow the field count failed.

Heres the solution i have working currently.

thanks Tim

<%
' Variables
' *********
   Dim mySmartUpload
   Dim file
   Dim intCount
   intCount=0

' Object creation
' ***************
   Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")

' Upload Opp Image
    mySmartUpload.Upload
' Select each file
' ****************
   FieldCount = 1
   For each file In mySmartUpload.Files
   ' Only if the file exist
   ' **********************
      If not file.IsMissing Then

      'Generate Random file name
      dim max,min
      max=99999999
      min=00000001
      RanFileName = (Int((max-min+1)*Rnd+min))
      ' Add extension
      FileExt = "." & file.FileExt
      ' Merge Random File Name and extention
      FileName = RanFileName & FileExt
      If FieldCount = 1 Then
         file.SaveAs("/uploads/" & FileName)
      Else
           file.SaveAs("/files/" & FileName)
      End If
         Response.Write "File Uploaded: " & FileName & "<BR>"
End If
FieldCount = FieldCount + 1
Next



%>

TDA
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using variable as fieldname in SELECT statement elygp SQL Server 2000 3 April 26th, 2007 10:14 AM
How to refresh owner form on closing of child form akumarp2p C# 2005 0 December 22nd, 2006 10:27 AM
parent form from child form - urgent plz netfresher C# 1 November 8th, 2006 06:59 PM
Problem with fieldname dot notation apt566 ASP.NET 1.0 and 1.1 Basics 1 December 3rd, 2005 11:01 AM
Mysql Latin5 FieldName and SQL Problem FWN MySQL 0 October 12th, 2003 01:40 AM



All times are GMT -4. The time now is 09:24 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.