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

3-Function Action Page

Guest
Apr 10, 2008 Apr 10, 2008
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
712
Translate
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
cfdump is your freind.

submit your form without uploading a file. then do this

<cfdump var="#isDefined('Form.FileContents') "#>
<cfdump var="#Form.#">
<cfabort>
Translate
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
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
Translate
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
Dumping variables is a debugging technique. Once you have solved the problem, you take out the dump tags.
Translate
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

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

Translate
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
Yes:

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


Thanks-

newportri
Translate
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
Probably you've already tried changing the order of processing:
a) data capture;
b) file manipulation;
c) email
Translate
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
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
Translate
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
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!
Translate
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
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 ...
Translate
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