ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old February 5th, 2004, 03:32 PM
scarickhoff scarickhoff is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 5 scarickhoff User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Issue with cffile & SQL

I am trying to create webmail app.

I have compose.cfm. After the user is finished and submits the data, it stores the message in an Access file.

The user can add up to three attachments. I want to be able to insert each attachment file name into 1 Access field (attachments) using commas to seperate the names.

Using the #cffile.ClientFileName#.#cffile.ClientFileExt# code, how do I create distinct code for each of the three attachments?

<!--- START BY UPLOADING ATTACHMENTS --->
<cfif FORM.attachment1 NEQ "">
<cffile action="upload"
destination=#getMailUser.sendAttachmentDirectory#
nameConflict="overwrite"
fileField="FORM.attachment1">
</cfif>
<cfif FORM.attachment2 NEQ "">
<cffile action="upload"
destination=#getMailUser.sendAttachmentDirectory#
nameConflict="overwrite"
fileField="FORM.attachment2">
</cfif>
<cfif FORM.attachment3 NEQ "">
<cffile action="upload"
destination=#getMailUser.sendAttachmentDirectory#
nameConflict="overwrite"
fileField="FORM.attachment3">
</cfif>
<!--- MAX THREE ATTACHMENTS UPLOADED --->
<!--- BEGIN SQL INSERT INTO STATEMENT FOR SAVING A COPY IN SENT ITEMS FOLDER --->
<cfquery datasource=#DSNwebmail#>
INSERT INTO MailMessages
(mailid, em_date, from_address, to, cc, bcc, attachmentDirectory, attachment, subject, body, folder)
VALUES
(
#SESSION.MM_webmail#,
'#DateFormat(Now(), "mm/dd/yy")#',
'#getMailUser.email#',
'#FORM.to#',
'#FORM.cc#',
'#FORM.bcc#',
'#getMailUser.sendAttachmentDirectory#',
'
<cfif #FORM.attachment1# NEQ "">#cffile.ClientFileName#.#cffile.ClientFileExt#</cfif>
<cfif #FORM.attachment2# NEQ "">, #cffile.ClientFileName#.#cffile.ClientFileExt#, </cfif>
<cfif #FORM.attachment3# NEQ "">#cffile.ClientFileName#.#cffile.ClientFileExt#</cfif>
',
'#FORM.subject#',
'#FORM.body#',
'Sent Items');
</cfquery>

Reply With Quote
  #2  
Old February 5th, 2004, 06:11 PM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,480 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 17 h 33 m 17 sec
Reputation Power: 42
CFFILE action="upload" should allow you specifiy a "fileField" attribute. You should be able to have multiple CFFILE tags, one for each file field name.

However, if you want to store the name of the file in a database after the upload, you'll need to copy each value for the file name to a temporary variable becuase that gets overwritten as each CFFILE tag is processed.

Last edited by kiteless : February 5th, 2004 at 06:20 PM.

Reply With Quote
  #3  
Old February 5th, 2004, 07:42 PM
scarickhoff scarickhoff is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 5 scarickhoff User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
So, something like this:

<cfparam name="Attach1" default="#cffile.ClientFileName#.#cffile.ClientFileExt#">

In these statements?
<cfif FORM.attachment1 NEQ "">
<cfmailparam file="#getMailUser.sendAttachmentDirectory#\#cffile.ClientFileName#.#cffile.ClientFileExt#">
<cfparam name="Attach1" default="#cffile.ClientFileName#.#cffile.ClientFileExt#">
</cfif>
<cfif FORM.attachment2 NEQ "">
<cfmailparam file="#getMailUser.sendAttachmentDirectory#\#cffile.ClientFileName#.#cffile.ClientFileExt#">
<cfparam name="Attach2" default="#cffile.ClientFileName#.#cffile.ClientFileExt#">
</cfif>
<cfif FORM.attachment3 NEQ "">
<cfmailparam file="#getMailUser.sendAttachmentDirectory#\#cffile.ClientFileName#.#cffile.ClientFileExt#">
<cfparam name="Attach3" default="#cffile.ClientFileName#.#cffile.ClientFileExt#">
</cfif>

Reply With Quote
  #4  
Old February 5th, 2004, 07:51 PM
scarickhoff scarickhoff is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 5 scarickhoff User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Wait... got it....

<cfif FORM.attachment1 NEQ "">
<cffile action="upload"
destination=#getMailUser.sendAttachmentDirectory#
nameConflict="overwrite"
fileField="FORM.attachment1">
<cfparam name="Attach1" default="#cffile.ClientFileName#.#cffile.ClientFileExt#">
<cfelse>
<cfparam name="Attach1" default="">
</cfif>

Works awesome. Thanks for the tip.

Reply With Quote
  #5  
Old February 5th, 2004, 09:14 PM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,480 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 17 h 33 m 17 sec
Reputation Power: 42
You can clean it up even further by eliminating the <cfelse> and avoiding the NEQ operator:

<cfset attach1="">
<cfset attach2="">
<cfset attach3="">

<cfif not len( form.attachment1 )>
<cffile action="upload"
destination=#getMailUser.sendAttachmentDirectory#
nameConflict="overwrite"
fileField="form.attachment1">
<cfset attach1="#cffile.ClientFileName#.#cffile.ClientFileExt#">
</cfif>

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Issue with cffile & SQL


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway