10 Replies Latest reply on Jul 5, 2007 6:35 AM by adelaidemocha

    <cfif> problem

    adelaidemocha
      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>