• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

3-Function Action Page

New Here ,
Apr 10, 2008 Apr 10, 2008

Copy link to clipboard

Copied

Greetings
I am having an issue with a form submission action page- I can get it to send the field contents to an email, and capture in a DB with the same action page- but when an file is chosen to upload, it fails.

I need to have cfinsert, cfmail to, and cffile action = "upload" on the same action page. The submitter may or may not upload a file with the submission, so I tried <cfif isDefined("Form.FileContents") > upload the file</cfif>, then insert in DB, then send the email.

Any help would be appreciated- Thanks

newportri
TOPICS
Advanced techniques

Views

638

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 10, 2008 Apr 10, 2008

Copy link to clipboard

Copied

cfdump is your freind.

submit your form without uploading a file. then do this

<cfdump var="#isDefined('Form.FileContents') "#>
<cfdump var="#Form.#">
<cfabort>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 10, 2008 Apr 10, 2008

Copy link to clipboard

Copied

Thanks for your quick response- It may be easier to show the code on the action page, then you can suggest a fix because I don't know why I'd dump the variables?

The Submitter is not required to upload a file with their submission (They may or may not).

ACTION PAGE:

<cfif isDefined("Form.FileContents") >
<cffile action = "upload"
filefield = "FileContents"
destination = "c:\Inetpub\wwwroot\whatever\"
accept = "image/jpg,image/jpeg,image/pjpeg,image/gif,text/anytext,application/octet-stream"
nameConflict = "MakeUnique"> </cfif>



<cfinsert datasource="whatever" tablename="whatever">


<cfmail to="whatever@whatever.com"
from="#Form.request_email#"
subject="whatever"
server ="whatever">


The following is the result of a Form Submission:

Date: #dte_received#
Time: #tme_received#

ETC.
</cfmail>

<html>
<head>
<title> Form Submission</title>
</head

<body>
<h3>Thank You For Your Submission</h3>
</body>
</html>

Thanks...

newportri

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 10, 2008 Apr 10, 2008

Copy link to clipboard

Copied

Dumping variables is a debugging technique. Once you have solved the problem, you take out the dump tags.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 10, 2008 Apr 10, 2008

Copy link to clipboard

Copied


How's your FORM written? Did you have the enctype="multipart/form-data" Attribute?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 11, 2008 Apr 11, 2008

Copy link to clipboard

Copied

Yes:

<form action="request_support_action.cfm" method="post" enctype="multipart/form-data">


Thanks-

newportri

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 11, 2008 Apr 11, 2008

Copy link to clipboard

Copied

Probably you've already tried changing the order of processing:
a) data capture;
b) file manipulation;
c) email

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 11, 2008 Apr 11, 2008

Copy link to clipboard

Copied

Greetings

Thanks- When the data capture is first, it looks for the form input name ,

ERROR=

"The FILECONTENTS fieldname cannot be found in the main table."

This is not a named field in the DB- I'm simply storing the file in a directory.

When the file manipulation is first with no file attached with the submitted form,

ERROR=

The form field FileContents did not contain a file.


Thanks again

newportri

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 11, 2008 Apr 11, 2008

Copy link to clipboard

Copied

Thanks to all who responded - I found the solution-

Sequence-

1) Data capture

2) Mail to

3) <cfif #Form.FileContents# IS "">
<cfabort>
<cfelse>
<cffile action = "upload"
filefield = "FileContents"
destination = "c:\whatever"
accept = "image/jpg,image/jpeg,image/pjpeg,image/gif,text/anytext,application/octet-stream"
nameConflict = "MakeUnique"> </cfif>


Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 11, 2008 Apr 11, 2008

Copy link to clipboard

Copied

LATEST
Actaully they shouldn't make any difference, but the sequence I wrote is my preference. Also, make sure to use cftry and cfcatch for each process ...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation