cfif problem

I'm trying to evalute whether a user is uploading an MS Word
file with spaces in the filename. We cannot have spaces in
filenames on our Internet site. So, basically, on the form page
there is a field with a browse box for user to select their file.
It's is passed to the action page; here's the code.
I've used the same <cfif> statement on a bare bones
page & it does work but for some reason it is not working on
this page. I'm wondering if there's code on this page preventing it
from being evaluted.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN">
<html>
<head>
<title>Human Resources Job Bank Form
Action</title>
</head>
<body>
<!-- Check for spaces in filename -->
<cfif form.positionfile CONTAINS " ">
The document you attached to this position contains spaces in
the filename. We cannot post documents containing spaces or special
characters on the Internet.<br><br>
<b>How to fix the problem
&#8212;</b><br><br>
<OL>
<LI>Please rename the original file without using
spaces or punctuation. <br><br>The following characters
are approved for file naming on the Web.
<ul type="square">
<li>Letters A-Z and a-z
<li>Numerals 0-9
<li>Dashes ( - )
<li>Underscores ( _ )
</ul>
<br>
<LI>Use your web browser's <b>Back</b>
button to return to <b>Post a Position in the Job
Bank</b> and reattach the position using the "Upload
Document" box.<br><br>
<LI>Resubmit the position using a compatible filename.
<BR><BR>
</OL><BR>
<cfelse>
<!--- capture the autonumber position id for use in the
uploads table --->
<cflock name="#CreateUUID()#" timeout="20">
<cftransaction>
<!--- Insert the position info into the main positions
table --->
<CFQUERY NAME="Insertposition"
DATASOURCE="#Application.DSN#">
Insert into positions
(title, medcenterID, otherlocation, areaID, carelineID,
grade, emailID, opendate, closedate)
VALUES
('#FORM.title#','#FORM.medcenterid#','#FORM.otherlocation#','#FORM.areaID#','#FORM.carelin eid#','#FORM.grade#','#FORM.emailID#','#FORM.opendate#','#FORM.closedate#')
</CFQUERY>
<cfquery DATASOURCE="#Application.DSN#"
name="getLastID">
SELECT MAX(positionID) as lastID
FROM positions
</cfquery>
</cftransaction>
</cflock>
<!--- Confirm to the user that the position was
successfully added, allow them to add another or see the master
list --->
<cfoutput>#DateFormat(createodbcdate(Now()),'mm/dd/yyyy')#
<br>
Position ID #getlastid.lastid#: #Form.Title#</cfoutput>
has been added to the HR Job Bank.<br><br>
<!--- upload the file to the directory and only accept
word docs --->
<cffile action="UPLOAD" filefield="positionfile"
destination="#application.uploaddirectory#"
nameconflict="MAKEUNIQUE">
<!--- Fill in the uploads table with the name and path for
the uploaded file --->
<CFQUERY NAME="CreateDocumentRecord"
DATASOURCE="#Application.DSN#">
INSERT INTO Uploads (positionID, Date_Published, File_Name,
Upload_Path)
VALUES
('#VAL(getlastid.lastid)#',#createodbcdate(Now())#,'#FILE.ClientFile#','#FILE.ServerFile# ')
</CFQUERY>
</cfif>
<!--- Grab Medical Center Name --->
<CFQUERY name="getmedicalcenter"
DATASOURCE="#Application.DSN#">
SELECT medcenterID, medcenter_name
FROM location
WHERE medcenterID = #form.medcenterID#
</CFQUERY>
<!--- Grab Area Name --->
<CFQUERY name="getarea" DATASOURCE="#Application.DSN#">
SELECT areaID, area_name
FROM areaofconsideration
WHERE areaID = #form.areaID#
</CFQUERY>
<!--- Grab Care Line Name--->
<CFQUERY name="getcareline"
DATASOURCE="#Application.DSN#">
SELECT carelineID, careline_name
FROM carelines
WHERE carelineID = #form.carelineID#
</CFQUERY>
</cfif>
</body>
</html>

The form page has sent you a temporary filename that does not
contain the space - therefore, it passes the CFIF test. A
workaround would be to do a CFDIRECTORY ACTION="list" to obtain the
filename of the most recent timestamp and do a CFFILE
ACTION="rename" if you find a space in the filename.

Similar Messages

  • Cfif select option value problem

    I have a form with a dropdown box asking users to select
    where they
    heard about my site. The completed form sent to me via email.
    The dropdown is optional so if they don't select it I would
    like nothing
    to be returned in the email.
    The first option reads "I heard about you from" - I've tried
    <option
    value> <option value=""> and even <cfselect>
    with various options but I
    can't get it to work.
    This is what I have for the email:
    <cfif
    isdefined("form.referral")><cfoutput>#form.senderFirst#
    heard
    about you from #form.referral#</cfoutput></cfif>
    This is what I have for the select options:
    <select name="referral">
    <option value="">I heard about you
    from...</option>
    <option value="Google">Google</option>
    <option value="Yahoo!">Yahoo!</option>
    <option value="Ask">Ask</option>
    <option value="MSN">MSN</option>
    <option value="a friend">A friend</option>
    <option value="somewhere else">Somewhere
    else</option>
    </select>

    Radio buttons and checkboxes are the only form elements that
    do not have a default value, so the others will always be defined.
    <cfif IsDefined ("form.senderPhone") AND
    Len(Trim(FORM.senderPhone)) GT 0>
    <p>Phone:
    <cfoutput>#form.senderPhone#</cfoutput></p>
    </cfif>
    <cfif IsDefined("form.senderMessage") AND
    Len(Trim(FORM.senderMessage)) GT 0>
    <p>Message:
    <cfoutput>#ParagraphFormat(form.senderMessage)#</cfoutput>
    </p>
    </cfif>
    Probably a more elegant way to do this but I can't think of
    it right now.
    <cfparam name="FORM.webSiteDesign" default="no">
    <cfparam name="FORM.graphicDesign" default="no">
    <cfparam name="FORM.logoDesign" default="no">
    <cfif FORM.webSiteDesign EQ "yes" OR FORM.graphicDesign EQ
    "yes" OR FORM.logoDesign EQ "yes">
    <p>
    Interested in:<br>
    <cfif FORM.webSiteDesign EQ "yes">
    webSiteDesign <br>
    </cfif>
    <cfif FORM.graphicDesign EQ "yes">
    graphicDesign<br>
    </cfif>
    <cfif FORM.logoDesign EQ "yes">
    logoDesign<br>
    </cfif>
    </p>
    </cfif>
    Ken Ford
    Adobe Community Expert
    Fordwebs, LLC
    http://www.fordwebs.com
    "ryansebiz" <[email protected]> wrote in
    message news:[email protected]...
    > dempster wrote:
    >> Why not use something like <option value="X">
    and then test this way:
    >>
    >> <cfif isdefined("form.referral") AND
    form.referral NEQ "X">
    >> <cfoutput>#form.senderFirst# heard about you
    from #form.referral#</cfoutput>
    >> </cfif>
    >
    > Thanks dempster that worked!
    >
    > Now I'd like to be able to do the same thing to a phone
    text box, a few
    > checkboxes and a textarea.
    >
    > None of the code below works - they all return messages
    (i.e. "Phone:"
    > "Interested in:" and "Message:") even if that field
    isn't filled out.
    > I've tried several different variables with no success.
    >
    > My questions are:
    >
    > 1. Phone - How can I write the cfif so the "Phone:"
    doesn't appear in
    > the email if a phone number isn't entered?
    >
    > 2. Checkboxes - The problem here isn't with the boxes
    themselves, but
    > with the "Interested in. Currently I have it set to
    "WebSiteDesign". The
    > obvious problem here occurs when they check another box,
    such as
    > "GraphicDesign". I've tried OR statements with no
    success. How can I
    > write a cfif for the exclusion of "Interested in" in the
    email if no
    > checkboxes are selected?
    >
    > 3. Textarea - What do I need to change in order for the
    email not to
    > display "Message:" if no message is entered?
    >
    > Here's the code:
    >
    > PHONE
    >
    > <!---Appears in the email--->
    >
    > <cfif IsDefined ("form.senderPhone")>
    > <p>Phone:
    <cfoutput>#form.senderPhone#</cfoutput></p>
    > </cfif>
    >
    > <!---Appears on the page--->
    >
    > <cfinput type="Text"
    > name="senderPhone"
    > message="Please enter your area code and phone number."
    > mask="999-999-9999"
    > validate="telephone"
    > validateat="onsubmit,onserver"
    > size="30"
    > maxlength="16">
    >
    >
    >
    >
    > CHECKBOXES
    >
    > <!---Appears in the email--->
    >
    > <cfif IsDefined("form.webSiteDesign")>
    > <p>Interested in:</p>
    > </cfif>
    >
    > <ol>
    > <cfif isdefined("form.webSiteDesign")>
    > <li>Web site design</li>
    > </cfif>
    > <cfif isdefined("form.graphicDesign")>
    > <li>Graphic design</li>
    > </cfif>
    > <cfif isdefined("form.logoDesign")>
    > <li>Logo design</li>
    > </cfif>
    > </ol>
    >
    >
    > <!---Appears on the page--->
    >
    > <p class="boxes">
    > <cfinput type="checkbox" name="webSiteDesign"
    value="yes">
    > Web site design</p>
    >
    > <p class="boxes">
    > <cfinput type="checkbox" name="graphicDesign"
    value="yes">
    > Graphic design</p>
    >
    > <p class="boxes">
    > <cfinput type="checkbox" name="logoDesign"
    value="yes">
    > Logo design</p>
    >
    >
    >
    >
    > TEXTAREA
    >
    > <!---Appears in the email--->
    >
    > <cfif IsDefined("form.senderMessage")>
    > <p>Message:
    >
    <cfoutput>#ParagraphFormat(form.senderMessage)#</cfoutput></p>
    > </cfif>
    >
    >
    > <!---Appears on the page--->
    >
    > <textarea name="senderMessage" cols="44" rows="6"
    wrap="virtual">
    > </textarea>

  • Cfif with or problem

    hi
    i'm trying to use multiple expressions in a cfif
    ex:
    <cfif (Evaluate(test.itemcode) is not "HDMI") OR (Evaluate(itemcode) is not "DVI")>
    this should result in returning everything that 's not with hdmi or dvi , right? it doesn't , it returns everything including them
    but when I do:
    <cfif (Evaluate(test.itemcode) is not "HDMI")>
    it excludes the hdmi from the list...
    what am I doing wrong?

    ok , i did a litle more testing... as I thought already , the evaluate didn't do anything wrong and is needed because of some other code...
    you were right on the other hand on the OR ... i changed it to AND ... and magic happened.... still baffled why though...
    if i was writing diagrams it would've been or... because:
    if the item in the loop is not hdmi or dvi or ....
         do this
    so it seemed more logical to me that way

  • Problem with QofQ and Null Values

    Just converted from CF5 to CF7. Finally figured out what was
    causing the error message :
    "The value "" cannot be converted to a number" when running a
    QofQ. It happens whenever there is a NULL (and I think a ZERO)
    value in the QofQ. I'm using the QofQ in a seperate chart program.
    The main query merges data from a store and a region table.
    I'm doing a LEFT OUTER JOIN to combine the REGION with the STORE,
    AND so that stores with NO SALES for a given day will show up as
    ZERO. On the main report, when I don't use a QofQWhen grouping by
    DAY or MONTH, I can test the value in the CFOUTPUT for NULL or ZERO
    and display "0" or "N/A" on the report.
    But when I try to chart it, using a QofQ to read in the
    values from the main query, and format the numbers, I get this
    error message. I've tried using the CAST function, using FLOAT,
    DOUBLE, BIGINT, etc., but still get same error message.
    The only way I could fix this is to add a WHERE statement to
    the QofQ, that only includes sales values greater than ZERO. But
    then, I have gaps in my chart because stores with NO SALES for a
    given day or MONTH don't appear. Because they are removed from the
    query. The whole point of LEFT JOINS is to include items with no
    values (or NULL) values.
    Does anyone know if it's possible to keep these values in a
    QofQ? So that items (e.g., store locations in my case) with NULL or
    ZERO values for some or all days or months can be charted? Even
    with a ZERO value? I've read everything I can get my hands on
    regarding QofQ, the CAST function, etc., but nothing seems to work.
    Thanks for any help. (FYI, didn't have this problem with CF5. It's
    QofQ could handle NULL or ZERO values without providing an error).
    Gary

    Well, I tried the IsNull function on the 3 SUM() values I was
    calculating in my SELECT statement (on a LEFT OUTER JOIN QUERY),
    and I STILL got another "cannot convert "" to a number" but this
    time the error message was more direct, and pointed me to a DATE
    field in my query, where I was SORTING AND GROUPING either by DAY
    or MONTH (depending on what user selected on form).
    In my QofQ, I'm not just reformating the integer SUM()
    values, but also the date values. So, I applied the IsNull()
    function to the DATE values in my main query. I still kept getting
    errors. But after experimenting ((SQL Server BOL docs doesn't give
    ISNULL() examples for DATE FIELDS, only NUMBER fields), I tried
    putting the dates in SINGLE QUOTES in my IsNull() function, the
    QUERY RAN. Then I wasn't sure WHAT date to enter, e.g., 1/1/1889 or
    1/1/2001, etc.
    Then, I discovered, after experimenting, that you cannot just
    blindly enter ANY date when using IsNull in a date field,
    especially if you are using CFGRAPH to chart the results by day.
    You have to select a date within the date range the user selected,
    so this means using the FORM.DATE (or URL.DATE) value from the
    form. Here's the working example from my SELECT main query:
    SELECT SUM(ISNULL(d.ttldb,0)) AS SumOfDB,
    SUM(ISNULL(d.ttldbv,0)) AS SumOfDBV,
    SUM(ISNULL(d.ttldbi,0)) AS SumOfDBI,
    <CFIF '#url.reptype#' IS "DAILY">
    ISNULL(d.depday, '#url.date1#') AS depday
    <CFELSE>
    month(ISNULL(d.depday, '#url.date2#')) AS TranMonth,
    year(ISNULL(d.depday, '#url.date2#')) AS TranYear
    </CFIF>
    Then I discovered that whatever date was used in the URL.DATE
    field (in my case it would be one of the two date field from the
    form, and depended on whether you coded DATE1 or DATE2, the chart
    would always show ZERO values for that date. So I tried putting the
    IsNull() date values in the GROUP BY and ORDER BY statements, e.g.,
    <CFIF '#url.reptype#' IS "DAILY">
    GROUP BY ISNULL(d.depday, '#url.date1#')
    ORDER BY ISNULL(d.depday, '#url.date1#') DESC
    <CFELSE>
    GROUP BY year(ISNULL(d.depday, '#url.date2#')),
    month(ISNULL(d.depday, '#url.date2#'))
    ORDER BY year(ISNULL(d.depday, '#url.date2#')),
    month(ISNULL(d.depday, '#url.date2#'))
    </CFIF>
    And this worked. The report ran just fine, and the chart
    charted every value correctly.
    I guess you have to learn all the little "quirks" about CF7
    and how it's QofQ and chart programs work. But so far, so good.
    Thank you all for your help. Now I've got to update other old
    CF5 programs that are returning errors when there are null values
    from my LEFT OUTER JOIN queries. Will take some time, but at least
    I know how to do it. Thanks to your help.
    I really appreciate your time and efforts to help with this
    issue.
    Gary

  • Problem with cfhttp in a loop

    Hi,
    I am reading an xml file that contains emails with attachments (one email per item/node, but may contain multiple attachments).  I am trying to save the attachments to our server.  So I'm looping over the multiple attachments of a single email and using cfhttp to GET the attachments from another server and save them with the same filename on our server.
    The problem is that it works for the first attachment - it's saved to the server, status code is 200 OK - awesome!  But for any attachments after that, it does not save them and throws a Conection Failure error.  No matter what attachments they are.
    In trouble shooting I tried several things.  First, inside of my loop of attachments, I can hardcode the cfhttp calls with the url and filename of the attachments - one right after the other - and all is perfect everytime!!  But it obviously needs to be dynamic.  I also tried to save a list of the attachment urls from the loop, and then call a separate cfhttp tag for each attachment in the list (so again, was in a loop) and it works for the first attachment in the list and not for the others (same errors as above).
    Here's a simplified version of the code.  I can't put in the real xml url, and when I set the "attachmentFilename" I left out that code because it works and is too much code.  Also, the XML works fine.  Please let me know if you have any suggestions, and of course, if you need more info from me!!
    Thanks so much,
    Kirsten
    <cfoutput>
    <cfhttp url="https://www.myxml.com/example.xml" method="get" resolveurl="no" />
    <cfset myXML = trim(cfhttp.FileContent)>
    <cfset myXML = xmlParse(myXML)>
    <cfset theRoot = myXML.XmlRoot>
    <cfset numChildren = arrayLen(theRoot.XMLChildren[1].XmlChildren)>
    <cfloop index="i" from="6" to="#numChildren#">
        <cfset attachments = theRoot.XMLChildren[1].XMLChildren[i]["attachments"].XmlText>
        <cfif ListLen(attachments, "|^|") gt 2>
            <cfset loop_unid = theRoot.XMLChildren[1].XMLChildren[i]["unid"].XmlText>
            <cfset counter = 0>
            <cfset attachmentArray = ListToArray(attachments, "|^|")>
            <cfloop from="1" to="#ArrayLen(attachmentArray)#" index="k">
                <cfset counter = counter + 1>
                <cfset attachmentURL = attachmentArray[k]>
                <cfset attachmentFilename = Replace(attachmentArray[k],"strip the url from the filename in the url","")>
                <cfhttp url="#attachmentURL#" method="get" resolveurl="no" timeout="120" path="D:\my_servers_path\attachmentFolder\" file="#attachmentFilename#">
                attachment counter: #counter#<BR />
                cfhttp.statusCode: #cfhttp.statusCode#<BR />
                cfhttp.errorDetail: #cfhttp.errorDetail#<BR />
            </cfloop>
        </cfif>
    </cfloop>
    </cfoutput>
    Output Results:
    attachment counter: 1
    cfhttp.statusCode: 200 OK
    cfhttp.errorDetail:
    attachment counter: 2
    cfhttp.statusCode: Connection Failure.  Status code unavailable.
    cfhttp.errorDetail: I/O Exception: peer not authenticated
    attachment counter: 3
    cfhttp.statusCode: Connection Failure.  Status code unavailable.
    cfhttp.errorDetail: I/O Exception: peer not authenticated

    We've seen the peer not authenticated error quite a bit on our CFHTTP calls - are you trying to access the URLs via HTTPS?  It seems the SSL certificate keystore that CF ships with does not contain all the vendor SSL certificates out there - when CF can't authenticate a cert, it throws that "Connection Failure / Peer not authenticated Error".  In order to fix the issue, you have to import the SSL certificate of the site you are trying to access into the CF cert store on your server(s).  If you are using multiple servers, you will have to import the cert on each server.
    I'm sure a google search will turn up a step by step guide on how to do this, but the basic steps are:
    Go to a page on the SSL server.
    Double-click the lock icon.
    Click the Details tab.
    Click Copy To File.
    Select the base64 option and save the file.
    Copy the CER file into ColdfusionDir\runtime\jre\lib\security
    Run the following command from the same directory (keytool.exe is located in ColdfusionDir\runtime\jre\bin) ..\..\bin\keytool.exe -import -keystore cacerts -alias UniqueName -file filename.cer
    Restart Coldfusion
    Hope that helps!
    - Michael

  • How to fix a problem with the order of strings in a JSON response for a CFHTTP request?

    Good morning, guys! (It's 10:50 a.m. in Brazil)
    First of all, I'm still new at CF and my questions may seem too much silly and my English's not the best, so, please be patient with me. hehe
    Well, I'm accessing a link via CFHTTP that gives me a JSON response. I'm not familiar with JSON yet, so I'm working it as a string and using string functions (Find,RemoveChars,Replace,etc), but it happens to me that I'm receiving a certain kind of order of the strings list from the JSON when I access it directly from the browser and other kind of order totally different when I access it from the CFHTTP.
    I only figured it out because I was working at home with my code and there everything went just fine as expected. Then I brought to my job to develop a little bit more as soon as I get a free time and here my code doesn't work anymore. When I took a look at the JSON by a CFOUTPUT, I realized the strings were in a different order.
    Does anyone know why is it happening?
    Link to the JSON: http://sigmine.dnpm.gov.br/ArcGIS/rest/services/extra/dados_dnpm/MapServer/0/query?text=83 0620/2012&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelInter sects&where=&returnGeometry=true&outSR=&outFields=FID,Shape,PROCESSO,ID,NUMERO,ANO,AREA_HA ,FASE,ULT_EVENTO,NOME,SUBS,USO,UF&f=pjson
    Basic code simplified to find out that the order of strings were coming different when access by CFHTTP:
    <cfhttp url="#URLAbove#" method="get" result="DadosDoDNPM" charset="utf-8" timeout="10000" />
    <cfset DadosJSON = deserializeJSON(DadosDoDNPM.FileContent) />
    <cfif arrayLen(DadosJSON.features)>
        <cfset CodigoFonteJSON = ToString(serialize(DadosJSON.features)) />   
        <cfoutput> #CodigoFonteJSON# </cfoutput>
    </cfif>
    Is there a way to fix it and to make my code work everywhere?
    If it matters, I use Railo at home and at my job.
    Since now, I thank you.

    When you deserialize JSON data, ColdFusion converts it into native structures and arrays (roughly equivalent to JavaScript objects and arrays).  In ColdFusion, structures are unordered (that is, they don't maintain keys in any particular ordered sequence).
    This really shouldn't be a problem though, at least not if you just want to work with the data contained in the deserialized JSON structure.  So DadosJSON should be a native ColdFusion structure, and you can interact with it like any other structure in ColdFusion.  In fact, you should not have to re-serialize it at all unless you need to send it to an external application using JSON.
    Why are you reserializing the data?  And why use serialize() instead of serializeJSON()?
    -Carl V.

  • Problem with Multi File upload example, help needed

    I got the code from the following location.....
    http://www.adobe.com/devnet/coldfusion/articles/multifile_upload.html
    And I've got it to work to some degree except I cant get the file transfer to work when pressing, Upload.   Below is what my debugger outputs.  Any thoughts on how to fix this or even what it means?
    At the very bottom of this message is the upload.cfm code.......
    Thanks in advance for the help
    <html>
    <head>
      <title>Products - Error</title>
    </head>
    <body>
    <h2>Sorry</h2>
    <p>An error occurred when you requested this page.
    Please email the Webmaster to report this error.
    We will work to correct the problem and apologize
    for the inconvenience.</p>
    <table border=1>
    <tr><td><b>Error Information</b> <br>
      Date and time: 12/07/09 22:25:51 <br>
      Page:  <br>
      Remote Address: 67.170.79.241 <br>
      HTTP Referer: <br>
      Details: ColdFusion cannot determine how to process the tag &lt;CFDOCUMENT&gt;. The tag name may be misspelled.<p>If you are using tags whose names begin with CF but are not ColdFusion tags you should contact Allaire Support. <p>The error occurred while processing an element with a general identifier of (CFDOCUMENT), occupying document position (41:4) to (41:70).<p>The specific sequence of files included or processed is:<code><br><strong>D:\hshome\edejham7\edeweb.com\MultiFileUpload\upload.cfm      </strong></code><br>
      <br>
    </td></tr></table>
    </body>
    </html>
    <!---
    Flex Multi-File Upload Server Side File Handler
    This file is where the upload action from the Flex Multi-File Upload UI points.
    This is the handler the server side half of the upload process.
    --->
    <cftry>
    <!---
    Because flash uploads all files with a binary mime type ("application/ocet-stream") we cannot set cffile to accept specfic mime types.
    The workaround is to check the file type after it arrives on the server and if it is non desireable delete it.
    --->
        <cffile action="upload"
                filefield="filedata"
                destination="#ExpandPath('\')#MultiFileUpload\uploadedfiles\"
                nameconflict="makeunique"
                accept="application/octet-stream"/>
            <!--- Begin checking the file extension of uploaded files --->
            <cfset acceptedFileExtensions = "jpg,jpeg,gif,png,pdf,flv,txt,doc,rtf"/>
            <cfset filecheck = listFindNoCase(acceptedFileExtensions,File.ServerFileExt)/>
    <!---
    If the variable filecheck equals false delete the uploaded file immediatley as it does not match the desired file types
    --->
            <cfif filecheck eq false>
                <cffile action="delete" file="#ExpandPath('\')#MultiFileUpload\uploadedfiles\#File.ServerFile#"/>
            </cfif>
    <!---
    Should any error occur output a pdf with all the details.
    It is difficult to debug an error from this file because no debug information is
    diplayed on page as its called from within the Flash UI.  If your files are not uploading check
    to see if an errordebug.pdf has been generated.
    --->
            <cfcatch type="any">
                <cfdocument format="PDF" overwrite="yes" filename="errordebug.pdf">
                    <cfdump var="#cfcatch#"/>
                </cfdocument>
            </cfcatch>
    </cftry>

    Just 2 things in my test:
    1) I use no accept attribute. Coldfusion is then free to upload any extenstion.
    Restricting the type to application/octet-stream may generate errors. Also, it is unnecessary, because we perform a type check anyway.
    2) I have used #ExpandPath('.')#\ in place of #ExpandPath('\')#
    <cfif isdefined("form.filedata")>
    <cftry>
    <cffile action="upload"
                filefield="filedata"
                destination="#expandPath('.')#\MultiFileUpload\uploadedfiles\"
                nameconflict="makeunique">
            <!--- Begin checking the file extension of uploaded files --->
            <cfset acceptedFileExtensions = "jpg,jpeg,gif,png,pdf,flv,txt,doc,rtf"/>
            <cfset filecheck = listFindNoCase(acceptedFileExtensions,File.ServerFileExt)/>
    <!---
    If the variable filecheck equals false delete the uploaded file immediatley as it does not match the desired file types
    --->
            <cfif filecheck eq false>
                <cffile action="delete" file="#ExpandPath('.')#\MultiFileUpload\uploadedfiles\#File.ServerFile#"/>
                <cfoutput>Uploaded file deleted -- unacceptable extension (#ucase(File.ServerFileExt)#)</cfoutput>.<br>
            </cfif>
    Upload process done!
            <cfcatch type="any">
                There was an error!
                <cfdocument format="PDF" overwrite="yes" filename="errordebug.pdf">
                    <cfdump var="#cfcatch#"/>
                </cfdocument>
            </cfcatch>
    </cftry>
    <cfelse>
    <form method="post" action=<cfoutput>#cgi.script_name#</cfoutput>
            name="uploadForm" enctype="multipart/form-data">
            <input name="filedata" type="file">
            <br>
            <input name="submit" type="submit" value="Upload File">
        </form>
    </cfif>

  • Problem with a query inner-join

    Hello;
    I'm trying to innerjoin these 2 tables in my query for a page that will allow you to add / edit records. Right now, it's telling me I have a data mismatch. I don't see where I went wrong. Can someone help me out?
    This is my code:
    <cfparam name="url.CategoryID" type="integer" default="0">
    <cfparam name="subID" type="integer" default="#url.CategoryID#">
    <cfparam name="subName" default="">
    <cfparam name="CategoryID" default="">
    <cfparam name="Name" default="">
    <cfif url.CategoryID GT 0>
    <cfquery name="categRec" dataSource="#APPLICATION.dataSource#">
    SELECT merchSubCat.subName, merchSubCat.subID, Categories.CategoryID, Categories.Name
    FROM merchSubCat
    INNER JOIN Categories
        ON merchSubCat.CategoryID = Categories.CategoryID
    WHERE merchSubCat.subID = <cfqueryparam value="#url.CategoryID#" cfsqltype="cf_sql_integer">
    </cfquery>
    <!--- if the record was found, store the values --->
    <cfif categRec.RecordCount EQ 1>
    <cfset CategoryID = categRec.subID>
    <cfset subName = categRec.subName>
    <cfset CategoryID = categRec.CategoryID>
    <cfset Name = categRec.Name>
    </cfif>
    </cfif>
    this is my error:
    Error Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Type mismatch in expression.
    The error occurred in C:\Websites\187914kg3\admin\cms\merchant\merchSub-edit.cfm: line 16
    14 : INNER JOIN Categories
    15 :     ON merchSubCat.CategoryID = Categories.CategoryID
    16 : WHERE merchSubCat.subID = <cfqueryparam value="#url.CategoryID#" cfsqltype="cf_sql_integer">
    17 : </cfquery>
    18 :
    I don't see what I did wrong, can another pair of eyes see where I missed something?
    Thank you

    I changed it to number, and it works now.
    I have one other problem.. I'm trying to use a drop down menu in this form to edit a record. I want the drop down to show what is being used in the database when you go to edit a record. It runs on one query, to populate the select, but it pulls info from another and this isn't working. Actually, it's the innerjoin I just made.. can you help me?
    <!--- query that runs the select --->
    <cfquery name="catList" datasource="#APPLICATION.dataSource#">
    SELECT DISTINCT merchCategory.CategoryID, merchCategory.CatName AS cat_name
    FROM merchCategory
    ORDER BY CatName
    </cfquery>
    <cfselect enabled="No" name="CategoryID" size="1" class="smallText" multiple="no" query="catList" value="CategoryID" display="cat_name" queryPosition="below" selected="#categRec.Name#">
                      <option value="">--Select a Category--</option>
                  </cfselect>
    As you see, in the selected part of the tag, I'm trying to pull info from the other query we just fixed. I know this is wrong, how do I do this?

  • Query problem again

    Will I ever get this!
    I have a form template which runs fine (it registers a user
    of my discussino board):
    <h2>Register here to post comments to any forum on this
    site </h2>
    <form action="Education - Bulletin Board - Register -
    code.cfm" method="post">
    <p>
    <strong>Username: </strong>
    <input type="text" name="user" />
    </p>
    <p><br />
    <strong>Password: </strong>
    <input type="password" name="pass" />
    </p>
    <p><br />
    <strong>Your mother's maiden name (a security
    precaution if you forget your username/password and need to
    retrieve them): </strong>
    <input type="text" name="MaidenName" />
    </p>
    <p><br />
    <strong>Email address (optional - in case I need to
    contact you about your posts): </strong>
    <input type="text" name="email" />
    </p>
    <p><br />
    <p>
    <input type="submit" value="Register!" />
    <input type="button" value="Back"
    onClick="self.location='index.cfm';" />
    </p>
    </form>
    </body>
    Now I want to check if the username and password have been
    taken by a previous user so I use this code:
    <cfif NOT structIsEmpty(form)>
    <cfquery name="CheckUserName" datasource= "Education
    Forum">
    SELECT UserName, Count(UserName) as Duplicates
    FROM ForumUsers
    WHERE ForumUsers.UserName=#form.user#
    GROUPBY ForumUsers.UserName
    </cfquery>
    <cfquery name="CheckPassword" datasource= "Education
    Forum">
    SELECT PassWord, Count(PassWord) as Duplicates
    FROM ForumUsers
    WHERE ForumUsers.Password=#form.PassWord#
    GROUPBY Password
    </cfquery>
    I just count how many times the password has been used. If it
    has been used more than once I'll later ask the new user to enter a
    different password. Unfortunately, Coldfusion has a problem with
    this query. Specifically, it gives me the error:
    Access Driver] Syntax error (missing operator) in query
    expression 'ForumUsers.UserName=jimmy GROUPBY ForumUsers.UserName'.
    The Error Occurred in C:\CFusionMX\wwwroot\Education\Bulletin
    Board\Education - Bulletin Board - Register - code.cfm: line 7
    5 : WHERE ForumUsers.UserName=#form.user#
    6 : GROUPBY ForumUsers.UserName
    7 : </cfquery>
    8 : <cfquery name="CheckPassword" datasource= "Education
    Forum">
    9 : SELECT PassWord, Count(PassWord) as Duplicates
    SQL SELECT UserName, Count(UserName) as Duplicates FROM
    ForumUsers WHERE ForumUsers.UserName=jimmy GROUPBY
    ForumUsers.UserName
    DATASOURCE Education Forum
    VENDORERRORCODE -3100
    SQLSTATE 42000
    I've run into this before, but I don't seem to be able to
    grasp the general principle involved.
    I'd be very grateful if someone could explain the error in
    this particular case and how I can avoid the problem in the futre.
    Thanks, once again, very much in advance.

    Thanks for the suggestions. I've changed the code to
    incorporate the advice as far as I can. It now reads:
    <cfif NOT structIsEmpty(form)>
    <cfparam name = "form.user" default = 0>
    <cfparam name = "form.password" default = 0>
    <cfparam name = "form.Email" default = 0>
    <cfparam name = "form.MaidenName" default = 0>
    <cfquery name="CheckUserName" datasource= "Education
    Forum">
    SELECT Uname, Count(Uname) as Duplicates
    FROM ForumUsers
    WHERE ForumUsers.Uname='#form.user#'
    GROUPBY ForumUsers.Uname
    </cfquery>
    <cfquery name="CheckPassword" datasource= "Education
    Forum">
    SELECT Pword, Count(Pword) as Duplicates
    FROM ForumUsers
    WHERE ForumUsers.Pword="AK"
    GROUPBY Pword
    </cfquery>
    Unfortunately, it still fails giving me the same error:
    Access Driver] Syntax error (missing operator) in query
    expression 'ForumUsers.Uname='adk' GROUPBY ForumUsers.Uname'.
    The Error Occurred in C:\CFusionMX\wwwroot\Education\Bulletin
    Board\Education - Bulletin Board - Register - code.cfm: line 11
    9 : WHERE ForumUsers.Uname='#form.user#'
    10 : GROUPBY ForumUsers.Uname
    11 : </cfquery>
    12 : <cfquery name="CheckPassword" datasource= "Education
    Forum">
    13 : SELECT Pword, Count(Pword) as Duplicates
    SQL SELECT Uname, Count(Uname) as Duplicates FROM ForumUsers
    WHERE ForumUsers.Uname='adk' GROUPBY ForumUsers.Uname
    DATASOURCE Education Forum
    VENDORERRORCODE -3100
    SQLSTATE 42000
    I think its just a SQL error as I get the same failure
    message if I replace '#form.user#' with say 'GAK'.
    Any further suggestions would be greatly appreciated.
    P.S. I'm still a novice, so how would I use
    <cfqueryparam> tags here?

  • Server side validation for file type with cffil sent via cfmail problem

    Hello;
    I have a small app that I need to allow users to be able to use a form, and send me and email with a file attachment. I have it working nicely, I included file manipulation into the validation process of the form and required form fields. The problem I'm having, is this. I'm trying to create and instance where if they try and upload lets say a pdf, it throws and error: "You are trying to upload the wrong file, please try again we only accept bla bla bla" Problem is, even if I'm uploading the proper file, it's rejecting it and deleting it. Can someone help me fix this? I've tried a number of different ways and can't seem to get this to go off properly. I am posting some of the code. There is a ton, so I'm posting the main parts so you get the idea and see my variables.
    <!--- Declairing my variables and setting up form validation--->
    <cfparam name="FORM.descript" type="string" default=""/>
    <cfparam name="FORM.attachment_1" type="string" default=""/>
    <cfset arrErrors = ArrayNew( 1 ) />
    <cfset showForm = true>
    <cfif structKeyExists(form, "sendcomments")>
    <cfif NOT len(trim(FORM.name))>
    <cfset ArrayAppend(arrErrors,"Your Full Name!<br>") />
    </cfif>
    <!--- This is where the file error control is as you can see how the name is validated, the file will be dealt with in a similar maner--->
    <cfif NOT Len(Trim(FORM.attachment_1))>
    <cfset ArrayAppend(arrErrors,"You didn't attach a file!<br>") />
    <cfelseif ArrayLen( arrErrors )>
    <cftry>
    <cffile action="DELETE" file="#FORM.resume#"/>
    <cfcatch>
    <!--- File delete error. --->
    </cfcatch>
    </cftry>
    <cfelse>
    <!--- no errors with the file upload so lets upload it--->
    <cftry>
    <cfset request.AcceptImage="image/gif,image/jpg,image/jpeg,image/pjpeg,image/x-png">
    <cffile action="upload"
                     filefield="attachment_1"
                     accept="#request.AcceptImage#"
                     destination="c:\websites\187914Kg3\uploads\"
                     nameconflict="Makeunique">
    <!---
    Now that we have the file uploaded, let's
    check the file extension. I find this to be
    better than checking the MIME type as that
    can be inaccurate (so can this, but at least
    it doesn't throw a ColdFusion error).
    --->
    <cfif NOT ListFindNoCase("request.AcceptImage",CFFILE.ServerFileExt)>
    <cfset ArrayAppend(arrErrors,"Only JPEG, GIF, and PNG file formats are accepted!<br>") />
    <!---
    Since this was not an acceptable file,
    let's delete the one that was uploaded.
    --->
    <cftry>
    <cffile action="DELETE" file="#CFFILE.ServerDirectory#\#CFFILE.ServerFile#"/>
    <cfcatch>
    <!--- File Delete Error. --->
    </cfcatch>
    </cftry>
    </cfif>
    <!--- This is the code that is causing my problem. The above code is saying everything is not the proper file and rejecting it all--->
    Can anyone help me out. I can make more of this code available if needed. Like i said, there's a lot and I didn't want to dump it all out, this is the section creating the problem. There are no errors at this time, just rejecting all file types.
    thank you.

    It appears you are comparing your content_length with 1MB.
    1KB: 1024 bytes
    1MB: 1024*1024 bytes
    Let us use max allowable size of 25KB here and amend the second half of our code.
    <!--- Set max allowable file size in KB at the top --->
    <cfset maxFileSize = 25>
          <!--- Check if file is an image file of acceptable size --->
          <cfif (#reFindNoCase("gif|jpg|jpeg|pjpeg|png",myResult.clientFileExt, 1)# EQ 1) AND (#myResult.FileSize# LTE (#maxFileSize#*1024))>
                <!--- Retain if right file type and size --->
                <p>
                Your file <strong>#myResult.clientFile#</strong> has been uploaded successfully!<br />
                <a href="yourTemplate.cfm">Back</a></p>
                <!--- Otherwise if wrong type --->
          <cfelseif #reFindNoCase("gif|jpg|jpeg|pjpeg|png",myResult.clientFileExt, 1)# NEQ 1>
                <p>
                You are trying to upload a <strong>#myResult.clientFileExt#</strong> file, please try again. We only accept <strong>gif, jpg, jpeg, and png</strong>.
                </p>
                <!--- Delete unacceptable file and show form to user to try again--->  
                <cffile action="delete"  file="#svrFile#" />
                      <form method="post" action=#cgi.script_name# 
                      name="uploadForm" enctype="multipart/form-data">
                      <input name="attachment_1" type="file">
                      <br>
                      <input name="submit" type="submit" value="Try again!">
                </form>
                <!--- Or size too large --->
          <cfelseif #myResult.FileSize# GT (#maxFileSize#*1024)>
                <p>
                Your file was too large (<strong>#numberFormat(myResult.fileSize/1024, "____.__")# KB</strong>). Please try a smaller file!
                </p>
                <!--- Delete file and show form--->
                <cffile action="delete"  file="#svrFile#" />
                      <form method="post" action=#cgi.script_name# 
                      name="uploadForm" enctype="multipart/form-data">
                      <input name="attachment_1" type="file">
                      <br>
                      <input name="submit" type="submit" value="Try again!">
                </form>
          </cfif>
    </cfif>        <!--- Closes the cfif tag which started from the first half --->
    </cfoutput><!--- ditto --->

  • Tricky upload file problem

    Hi,
    I have created a page to allow people to upload a file, OR
    just insert the url of the file. I am getting errors when I choose
    the option not upload the file.
    The first page has two input fields, one is text and the
    other is file - they both go to the same page. And I use
    enctype="multipart/form-data" in the form header.
    The second page checks to see if the form variable containing
    the file name exists - if it does, it loads the file. If not, then
    it just uses the url supplied in the text field.
    I can upload a file ok, but when I don't want to upload a
    file, and just enter the url, it comes back with an error. Is what
    I am trying to do possible, or do I need two different forms with
    two different destination pages??

    quote:
    Originally posted by:
    cakesy
    Hi,
    I have created a page to allow people to upload a file, OR
    just insert the url of the file. I am getting errors when I choose
    the option not upload the file.
    The first page has two input fields, one is text and the
    other is file - they both go to the same page. And I use
    enctype="multipart/form-data" in the form header.
    The second page checks to see if the form variable containing
    the file name exists - if it does, it loads the file. If not, then
    it just uses the url supplied in the text field.
    I can upload a file ok, but when I don't want to upload a
    file, and just enter the url, it comes back with an error. Is what
    I am trying to do possible, or do I need two different forms with
    two different destination pages??
    Assuming you are doing as you have actually indicated, you
    pretty much figured out the problem already, but I'm not certain
    you realize it.
    With the exception of checkboxes (
    and some weird radio button configs) all form fields
    exist whether they are blank or not.
    What you should be doing on your action page is checking to
    see
    if the fields are blank,
    not whether they exist. Make sure you use the TRIM function
    when you do this as well so it's not possible for people to submit
    the field with just a space in it.
    <CFIF TRIM(fileformfield) NEQ "">
    do action for file upload
    </CFIF>
    <CFIF TRIM(urlformfield) NEQ "">
    do action for url addition
    </CFIF>
    You could use a CFELSE in there, but I prefer to test for
    either possibility since (
    theoretically) the form fields could be submitted with
    blanks in each of them. Also, (theoretically) they could submit the
    form with both fields completed, so then you may also want to
    incorporate some cross-testing so that if both are filled out, you
    either choose one as the default, or you send an error back to the
    user to choose one or the other.

  • Problem with calling onApplicationStart() method

    Hi all,
         I have a problem with calling application.cfc's methods from coldfusion template. The problem is like when i am calling "onapplicationstart" method inside a cfml template i getting the error shown below
    The onApplicationStart method was not found.
    Either there are no methods with the specified method name and argument types or the onApplicationStart method is overloaded with argument types that ColdFusion cannot decipher reliably. ColdFusion found 0 methods that match the provided arguments. If this is a Java object and you verified that the method exists, use the javacast function to reduce ambiguity.
    My code is like below.
    Application.cfc
    <cfcomponent hint="control application" output="false">
    <cfscript>
    this.name="startest";
    this.applicationtimeout = createtimespan(0,2,0,0);
    this.sessionmanagement = True;
    this.sessionTimeout = createtimespan(0,0,5,0);
    </cfscript>
    <cffunction name="onApplicationStart" returnType="boolean">
        <cfset application.myvar = "saurav">
    <cfset application.newvar ="saurav2">
        <cfreturn true>
    </cffunction>
    </cfcomponent>
    testpage.cfm
    <cfset variables.onApplicationStart()>
    I have tried to call the above method in different way also like
    1--- <cfset onApplicationStart()>
    i got error like this
    Variable ONAPPLICATIONSTART is undefined.
    2---<cfset Application.onApplicationStart()>
    The onApplicationStart method was not found.
    Either there are no methods with the specified method name and argument types or the onApplicationStart method is overloaded with argument types that ColdFusion cannot decipher reliably. ColdFusion found 0 methods that match the provided arguments. If this is a Java object and you verified that the method exists, use the javacast function to reduce ambiguity
    Please help me out.
    Thanks
    Saurav

    You can't just call methods in a CFC without a reference to that CFC. This includes methods in Application.cfc.
    What are you trying to do, exactly, anyway? You'd probably be better served by placing a call to onApplicationStart within onRequestStart in Application.cfc, if your goal is to refresh the application based on some condition:
    <cffunction name="onRequestStart">
         <cfif someCondition>
              <cfset onApplicationStart()>
         </cfif>
    </cffunction>
    Dave Watts, CTO, Fig Leaf Software
    http://www.figleaf.com/
    http://training.figleaf.com/

  • Problem with CFUPDATE porting from CF4 to CF7

    Hi, I am porting a site from CF4.1 to CF7 and am getting the
    following error in the site.
    Error Occurred While Processing Request
    The given fieldname "STYLE" could not be found in the table
    "OBJECTS".
    The error occurred in doeditobject.cfm: line 19
    18 : <CFIF SITEADMINPERMS is True OR SECTIONADMINPERMS is
    True OR EDITPERMS is True>
    19 : <CFUPDATE DATASOURCE="#SITENAME#" TABLENAME="OBJECTS"
    FORMFIELDS="TEXT,TITLE,LINK">
    20 : <CFLOCATION
    URL="main.cfm?Action=editobject&SID=#Form.SID#&LID=#URL.LID#&EDITTYPE=#URL.EDITTYPE#">
    21 : <CFELSE>
    STYLE is not given as a fieldname so I don't understand where
    to start with this error.
    Any thoughts. I know that I have not provided a lot of
    information but I am not sure what is relevant to this error.
    The three form fields mentioned contain text. TEXT field
    contains HTML to be written to the database.
    Thanks in advance for any help.
    Sean.

    My guess is it has something to do with the HTML. There may
    be a <style> tage that is causing the problem.
    Any chance you can just write the insert statement?

  • Cfqueryparam problem

    While cleaning up some sql injection problems, I found I had
    to rewrite how the inserts were working.
    I do not know in advance what fields need to be populated for
    inserts so I mad a generic function
    to make my inserts.
    <cffunction name="insertIntoTable" access="private"
    returntype="void">
    <cfargument name="table" type="string" required="yes">
    <cfargument name="datasource" type="string"
    required="yes">
    <cfargument name="keyValSet" type="struct"
    required="yes">
    <cfset var keyList = structKeyList(keyValSet)>
    <cfset var curKey = "">
    <cfset var curVal = "">
    <cfset var comma = "">
    <cfset var insertIntoTable = "">
    <cfquery datasource="#datasource#"
    name="insertIntoTable">
    insert into #table# (#keyList#)
    values (<cfloop list="#keyList#"
    index="curKey">#comma#<cfset comma = ","><cfset curVal
    = trim(keyValSet[curKey])><cfif len(curVal) eq
    0><cfqueryparam null="yes"><cfelse><cfqueryparam
    value="#curVal#"></cfif></cfloop>)
    </cfquery>
    <cfreturn>
    </cffunction>
    I know before this call is made that the table names and the
    keylist is clean.
    I found that I could not simply use a <cfqueryparam
    list="yes" ...> as some of
    the entries may be null.
    My current problem is when someone enters Joe's Crab Shack
    into a form field
    the corresponding data record results in Joe''s Crab Shack.
    I found a hotfix for CF MX 6.1 with something that sounded
    similar, however
    we are running CF 7.02 on redhat. The db server is an old MS
    SQL Server (8.00).

    It appears that the two single quotes problem occurs only
    when cfloop is used, which looks very similar to one of the
    problems the hotfix for CF MX 6.1 had.
    Has anyone else come across this problem?

  • Problems to restrict access to a page when the user belong to more than 1 group

    I have realized that Dreamweaver on a coldfusion document only works fine when the user only belongs to a single group, this is because the code supplied by dreamweave when you use the option "Restrict access to a page" at "Server behaviors" it assumes that the user only have one group as you can see on this line created automaticly by dreamweaver:
    <cfif MM_Username EQ "" OR MM_UserAuthorization EQ "" OR ListFind("admin",MM_UserAuthorization) EQ 0>
    MM_UserAutorization has the value of the field assigned for the list of groups or levels, as you can see it could work if we reverse the parameters of the listfind function but the problem would be if we grant the access to more than one group because the sentence would be like this:
    <cfif MM_Username EQ "" OR MM_UserAuthorization EQ "" OR ListFind("Admin,Manager",MM_UserAuthorization) EQ 0>
    so both paramethers are lists therefore no user will get access to the page.
    I am trying to make a work around to fix this problem but I don't know how to get the name of the page since the Application.cfc so I can validate the access to this page against tables on my database.
    Does someone have a work around or a tip how to fix this problem?
    Thanks in advance.
    AG

    Seems like you have a problem with your group names.ctxLdap.modifyAttributes(groupName,member);Ensure that the value of your variable groupName is a a valid distinguished name.
    Note that an OU (organizationalUnit) is not a group. You do not add users to OU's, you create users in OU's.

Maybe you are looking for