[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1634
  • Last Modified:

Attribute validation error for tag CFFILE.

Okay, so I have this page that a user sees after clicking on a class name in a listing of classes they need to complete.
Some classes issue certificates, and those certificates are to be submitted via the page below. The file is then uploaded to
a directory that is specific to that user. That directory contains all of their training certificates submitted. The certificates are renamed with the class name and the date of upload when they are uploaded.

My problem is that as of right now the files are being uploaded, but not renamed and I'm getting this error "Attribute validation error for tag CFFILE. "  along with this "The value of the attribute destination, which is currently C:\training\classes\certificates\123456789\, is invalid. "  (the 1 - 9 is a made up number for this posting and represents a user's ID#).


What am I doing wrong?  I've done 4 or five different sites with file uploads (using the majority of the script below) and I haven't had this problem before.


<cfinclude template="../../config.cfm">
<cfinclude template="../../includes/wdg/WDG.cfm">
<cfinclude template="../../includes/common/KT_common.cfm">
<cfinclude template="../../includes/tng/tNG.inc.cfm">
<cfinclude template="../../includes/nxt/KT_back.cfm">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml" xmlns:wdg="https://ns.adobe.com/addt">
<head>
<meta https-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Class Info</title>
<link rel="stylesheet" type="text/css" href="../../css/main.css" />
<script type="text/javascript" src="../../includes/common/js/sigslot_core.js"></script>
<script src="../../includes/common/js/base.js" type="text/javascript"></script>
<script src="../../includes/common/js/utility.js" type="text/javascript"></script>
<script type="text/javascript" src="../../includes/wdg/classes/MXWidgets.js"></script>
<script type="text/javascript" src="../../includes/wdg/classes/MXWidgets.js.cfm"></script>
<script type="text/javascript" src="../../includes/wdg/classes/Calendar.js"></script>
<script type="text/javascript" src="../../includes/wdg/classes/SmartDate.js"></script>
<script type="text/javascript" src="../../includes/wdg/calendar/calendar_stripped.js"></script>
<script type="text/javascript" src="../../includes/wdg/calendar/calendar-setup_stripped.js"></script>
<script src="../../includes/resources/calendar.js" type="text/javascript"></script>
<link href="../../includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />
<script src="../../includes/common/js/base.js" type="text/javascript"></script>
<script src="../../includes/common/js/utility.js" type="text/javascript"></script>
<script src="../../includes/skins/style.js" type="text/javascript"></script>
<script src="../../includes/resources/calendar.js"></script>
<!---GET CLASS DETAILS--->
<cfquery name="getClassDetail" datasource="#DSN#">
SELECT *
FROM training_courses
WHERE ID = '#URL.ID#'
</cfquery>
<!---CHECK THE USER TRAINING TABLE TO SEE IF THE EMPLOYEE HAS A RECORD ALREADY STARTED FOR THIS CLASS--->
<cfquery name="qCheckTraining" datasource="#DSN#">
SELECT ContactID, CourseID
FROM UserTraining
WHERE ContactID = '#SESSION.UserID#' 
AND CourseID = '#URL.ID#'
</cfquery>
<!--- SET certain variables for the processing of the form --->
<cfquery name="qGetUserDetail" datasource="#DSN#">
SELECT branch, email_address, EDIPI
FROM Contacts
WHERE EDIPI = '#SESSION.UserID#'
</cfquery>
<cfset UserEmail='#qGetUserDetail.email_address#'>
<!--- get the branch chief info for the employee's branch --->
<cfquery name="qGetBranchChief" datasource="#DSN#">
SELECT branch, email_address
FROM Contacts
WHERE branch = '#qGetUserDetail.branch#'
AND role = 'C'
</cfquery>
<cfset BranchChiefEmail='#qGetBranchChief.email_address#'>
<!---IF THE EMPLOYEE HAS A RECORD ALREADY FOR THIS CLASS GET THE DETAILS--->
<cfif qCheckTraining.recordcount NEQ 0 >
  <cfquery name="getUserTraining" datasource="#DSN#">
SELECT *
FROM UserTraining
WHERE ContactID = '#SESSION.UserID#' 
AND CourseID = '#URL.ID#'
</cfquery>
</cfif>
</head>
<body style="text-align:left; background: #FFFFFF;">
<br />
<cfif Not isDefined("QueryType")>
  <div style="text-align:left;">
    <form method="post" id="form2" class="training" enctype="multipart/form-data" >
      <fieldset style="margin-left:10px; margin-right:10px;">
      <legend> <cfoutput>#getClassDetail.course_name#</cfoutput> </legend>
      <ul>
        <li><span style="font-weight:bold; padding-right:10px;">Location:</span><a href="<cfoutput>#getClassDetail.website#</cfoutput>" target="_blank" ><cfoutput>#getClassDetail.website#</cfoutput></a> </li>
        <li><span style="font-weight:bold; padding-right:10px;">Priority:</span><cfoutput>#getClassDetail.priority#</cfoutput></li>
      </ul>
      <fieldset style="margin-left:10px; margin-right:10px; margin-top:20px;">
      <legend>Fill in form below when course is complete</legend>
      <ul>
        <li>
          <label for="ReqDate">Required Date:</label>
          <input type="text" name="ReqDate" id="ReqDate" value="<cfoutput>#LSDateFormat(getClassDetail.date,'MM/DD/YYYY')#</cfoutput>" size="30" maxlength="30" />
        </li>
        <li>
          <label for="completed">Completed:</label>
          <select name="completed" id="completed">
            <option value=""  <cfif NOT isDefined('getUserTraining.completed')>selected="selected"</cfif> >Select One</option>
            <option value="yes" <cfif isDefined('getUserTraining.completed') AND getUserTraining.completed EQ 'yes'> selected="selected" </cfif> >Yes</option>
            <option value="no"  <cfif isDefined('getUserTraining.completed') AND getUserTraining.completed EQ 'no'> selected="selected" </cfif>  >No</option>
            <option value="inprogress"  <cfif isDefined('getUserTraining.completed') AND getUserTraining.completed EQ 'inprogress'> selected="selected" </cfif> >In progress</option>
            <option value="postponed"  <cfif isDefined('getUserTraining.completed') AND getUserTraining.completed EQ 'postponed'> selected="selected" </cfif> >Postponed</option>
          </select>
        </li>
        <cfif (isDefined("getClassDetail.hour_requirement") AND "yes" EQ getClassDetail.hour_requirement)>
          <li>
            <label for="hours_completed">Hours Completed:</label>
            <select name="hours_completed" id="hours_completed">
              <option <cfif NOT isDefined("getUserTraining.hours_completed") >selected<cfelse></cfif>value="">Select One</option>
              <option <cfif (isDefined("getUserTraining.hours_completed") AND "1" EQ getUserTraining.hours_completed )>selected</cfif> value="1">1</option>
              <option <cfif (isDefined("getUserTraining.hours_completed") AND "2" EQ getUserTraining.hours_completed )>selected</cfif> value="2">2</option>
              <option <cfif (isDefined("getUserTraining.hours_completed") AND "3" EQ getUserTraining.hours_completed )>selected</cfif> value="3">3</option>
              <option <cfif (isDefined("getUserTraining.hours_completed") AND "4" EQ getUserTraining.hours_completed )>selected</cfif> value="4">4</option>
              <option <cfif (isDefined("getUserTraining.hours_completed") AND "5" EQ getUserTraining.hours_completed )>selected</cfif> value="5">5</option>
              <option <cfif (isDefined("getUserTraining.hours_completed") AND "6" EQ getUserTraining.hours_completed )>selected</cfif> value="6">6</option>
              <option <cfif (isDefined("getUserTraining.hours_completed") AND "7" EQ getUserTraining.hours_completed )>selected</cfif> value="7">7</option>
              <option <cfif (isDefined("getUserTraining.hours_completed") AND "8" EQ getUserTraining.hours_completed )>selected</cfif> value="8">8</option>
              <option <cfif (isDefined("getUserTraining.hours_completed") AND "9" EQ getUserTraining.hours_completed )>selected</cfif> value="9">9</option>
              <option <cfif (isDefined("getUserTraining.hours_completed") AND "10" EQ getUserTraining.hours_completed )> selected</cfif> value="10">10</option>
            </select>
            <span style="color:#FFFFFF;">Hours Required: <u> <cfoutput>#trim(getClassDetail.how_many_hours)#</cfoutput> &nbsp;
            <cfif isDefined("getUserTraining.hours_completed")>
              <cfset hours_remaining = getClassDetail.how_many_hours - getUserTraining.hours_completed >
              Hours Remaining: <u> <cfoutput>#hours_remaining#</cfoutput> </u>
            </cfif>
            </u></span></li>
          <cfelse>
        </cfif>
        <li>
          <label for="DateComplete">Date Completed:</label>
          <cfif isDefined('getUserTraining.DateComplete')>
            <input readonly="readonly" value="<cfoutput>#LSDateFormat(getUserTraining.DateComplete,'MM/DD/YYYY')#</cfoutput>" />
            <cfelse>
            <input name="DateComplete" id="DateComplete" value="" size="30" maxlength="22" wdg:subtype="Calendar" wdg:mask="<cfoutput>#Request.KT_screen_date_format#</cfoutput>" wdg:mondayfirst="false" wdg:type="widget" wdg:singleclick="true" wdg:restricttomask="yes" wdg:readonly="true" />
          </cfif>
        </li>
        <cfif isDefined("getUserTraining.Expiration") >
          <li>
            <label for="Expiration">Expiration:</label>
            <input type="text" name="Expiration" id="Expiration" value="<cfoutput>#getUserTraining.Expiration#</cfoutput>" size="30" maxlength="22" />
          </li>
          <cfelse>
        </cfif>
        <cfif isDefined("getClassDetail.cert_required") AND getClassDetail.cert_required EQ 'yes'>
          <li>
            <label for="uploadfile1">Upload Certificate:</label>
            <input  type="file" name="uploadfile1" id="uploadfile1" />
          </li>
        </cfif>
        <li>
          <label>&nbsp;</label>
          <cfset RightNow = Now()>
          <input type="hidden" name="TrainingFrequency" id="TrainingFrequency" value="<cfoutput>#getClassDetail.training_frequency#</cfoutput>" />
          <input type="hidden" name="CourseID" id="CourseID" value="<cfoutput>#URL.ID#</cfoutput>" />
          <input type="hidden" name="ContactID" id="ContactID" value="<cfoutput>#SESSION.UserID#</cfoutput>" />
          <input type="hidden" name="UpdateUser" id="UpdateUser" value="<cfoutput>#SESSION.UserName#</cfoutput>" />
          <input type="hidden" name="UpdateDate" value="<cfoutput>#LSDateFormat(RightNow,'MM/DD/YYYY')#</cfoutput>">
        </li>
        <cfif isDefined("getUserTraining.id") >
          <li>
            <label>&nbsp;</label>
            <input name="QueryType" type="submit" value="Update Training" />
          </li>
          <cfelse>
          <li>
            <label>&nbsp;</label>
            <input name="QueryType" type="submit" value="Insert Training" />
          </li>
        </cfif>
      </ul>
      </fieldset>
      </fieldset>
    </form>
  </div>
</cfif>
<!--- FORM ACTION CODE STARTS HERE --->
<cfif isDefined("FORM.DateComplete")>
  <cfparam name="DateCompleted" default="#DateFormat(FORM.DateComplete, 'MM/DD/YYYY')#">
</cfif>
<cfif isDefined("FORM.QueryType")>
  <cfparam name="QueryType" default="#FORM.QueryType#">
</cfif>
<cfset current_year = year(now())>
<!---Date manipulation CF--->
<cfif isDefined("FORM.DateComplete")>
  <cfparam name="frequency" default="#getClassDetail.training_frequency#">
  <cfif frequency EQ '1'>
    <cfparam name="ExpirationDate" default="#DateFormat(DateAdd('d',365, DateCompleted), 'MM/DD/YYYY')#" >
    <cfelseif frequency EQ '2'>
    <cfparam name="ExpirationDate" default="#DateFormat(DateAdd('d',183, DateCompleted), 'MM/DD/YYYY')#" >
    <cfelseif frequency EQ '3'>
    <cfparam name="ExpirationDate" default="NEVER" >
    <cfelseif frequency EQ '4'>
    <cfparam name="ExpirationDate" default="NEVER" >
    <cfelseif frequency EQ '5'>
    <cfparam name="ExpirationDate" default="12/31/#current_year#" >
    <!---Add code to get current year and set the Expiration field to the last day to 12/31/#current_year#--->
    <cfelseif frequency EQ '6'>
    <cfparam name="ExpirationDate" default="9/30/#current_year#" >
    <!---Add code to get current year and set the Expiration field to the last day to 09/30/#current_year#--->
  </cfif>
</cfif>
<!---///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////--->
<!---File Upload Script  START--->
<!--- create an array for the file details: --->
<cfset directory_name = '#SESSION.UserID#'>
<cfset currentDirectory = '#uploadDirectory##directory_name#'>
<cfset files = ArrayNew(1)>
<!---File Upload Script  START--->
<cfloop from="1" to="1" index="i" >
  <cfif isdefined("FORM.uploadfile"&i) and FORM["uploadfile"&i] GT "" >
    <!---Check that the directory exists to avoid getting a ColdFusion error message. --->
    <cfif DirectoryExists('currentDirectory')>
      <!--- If TRUE --->
      <cffile action="UPLOAD" filefield="FORM.uploadfile#i#" destination="#currentDirectory#\" nameconflict="overwrite" accept="application/msword, application/pdf, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.openxmlformats-officedocument.presentationml.presentation, application/rtf, image/gif, image/jpeg, image/tiff, image/bmp, text/plain">
      <cffile action="rename"  source="#currentDirectory#\#cffile.serverFile#" destination="#currentDirectory#\#getClassDetail.course_name#_#getClassDetail.date#.pdf" attributes="normal"/>
      <cfelse>
      <!---IF NOT TRUE--->
      <cffile action="UPLOAD" filefield="FORM.uploadfile#i#" destination="#currentDirectory#\" nameconflict="overwrite" accept="application/msword, application/pdf, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.openxmlformats-officedocument.presentationml.presentation, application/rtf, image/gif, image/jpeg, image/tiff, image/bmp, text/plain">
      <cffile action="rename"  source="#currentDirectory#\#cffile.serverFile#" destination="#currentDirectory#\#getClassDetail.course_name#_#getClassDetail.date#.pdf" attributes="normal"/>
      <cfdirectory action = "create" directory = "#currentDirectory#">
    </cfif>
    <!--- add the file info to our array --->
    <!--- append the file data to the array --->
    <cfset ArrayAppend(files, Duplicate(cffile))>
    <cfelse>
    <!--- append some value representing "no file"--->
    <cfset ArrayAppend(files, "")>
  </cfif>
</cfloop>
<!---File Upload Script END--->
<!---///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////--->
<!--- This part determines if the form input is for new training just finished or updating partially finished training --->
<cfif isDefined("QueryType")>
  <!--- This is the start of the INSERT new finished training --->
  <cfif QueryType EQ "Insert Training">
    <cfquery name="insertUserTraining" datasource="#DSN#" >   
INSERT INTO UserTraining 
    (ContactID, 
    CourseID, 
    ReqDate,
    Frequency, 
    completed, 
    <cfif isDefined("FORM.DateComplete")>
    DateComplete, 
    </cfif>
    Expiration,
    <cfif getClassDetail.hour_requirement EQ 'Yes'>
    Hours_Completed,
    </cfif>
    UpdateUser,
    UpdateDate)
    
values 
('#form.ContactID#', 
 '#form.CourseID#',
'#form.ReqDate#',
'#form.TrainingFrequency#', 
'#form.completed#',
<cfif isDefined("FORM.DateComplete")> 
'#DateCompleted#', 
</cfif>
'#ExpirationDate#',
<cfif getClassDetail.hour_requirement EQ 'Yes'>
'#Hours_Completed#',
</cfif>
'#form.UpdateUser#',
'#form.UpdateDate#' )
</cfquery>
    <!--- Set email variables --->
    <cfset to_email='#UserEmail#'>
    <!---<cfset cc_email='#BranchChiefEmail#'>--->
    <cfset cc_email='ronald.rattie@amedd.army.mil'>
    <cfset subject_line='#getClassDetail.course_name# training completed.'>
    <cfset from_email='XXXXXXXXXXXXXXXXXXXXXXl'>
    <!--- compose email message to employee and employee's team chief --->
    <cfmail
	TO="#to_email#"
	CC="#cc_email#"
	SUBJECT="#subject_line#"
	FROM= "#from_email#"
	TYPE= "HTML"
	SERVER="smtp.XXXXXXXXXXXXXXX"
	>
      #form.UpdateUser# has completed the following training: <br>
      <br>
      Class:&nbsp; <b>#getClassDetail.course_name#</b> <br>
      Date:&nbsp; <b>#DateCompleted#</b> <br>
      Due Date:&nbsp; <b>#LSDateFormat(getClassDetail.date,'MM/DD/YYYY')#</b> <br>
      <br/>
      **The training information was entered by #form.UpdateUser# on #form.UpdateDate# **
    </cfmail>
    <!--- END OF INSERT NEW TRAINING --->
    <!--- Start of the UPDATE partially finished training --->
    <cfelseif QueryType EQ "Update Training">
    <cfquery name="updateUserTraining" datasource="#DSN#">
UPDATE UserTraining
   SET completed = '#Form.completed#',
   <cfif isDefined("FORM.DateComplete")>
      DateComplete = '#DateCompleted#',
      </cfif>
      Expiration = '#ExpirationDate#',
      <cfif getClassDetail.hour_requirement EQ 'Yes'>
      Hours_Completed = '#Hours_completed#',
      </cfif>      
      UpdateUser = '#Form.UpdateUser#',
      UpdateDate = '#form.UpdateDate#' 
   WHERE ContactID = '#Form.ContactID#'
   AND CourseID = '#Form.CourseID#'
   AND ID = '#getUserTraining.ID#'
  
  </cfquery>
    <!--- Set email variables --->
    <cfset to_email='#UserEmail#'>
    <cfset cc_email='#BranchChiefEmail#'>
    <cfset subject_line='#getClassDetail.course_name# training completed.'>
    <cfset from_email='XXXXXXXXXXXXXXXXXXXXX'>
    <!--- compose email message to employee and employee's team chief --->
    <cfmail
	TO="#to_email#"
	CC="#cc_email#"
	SUBJECT="#subject_line#"
	FROM= "#from_email#"
	TYPE= "HTML"
	SERVER="smtp.XXXXXXXXXXXXXX"
	>
      #form.UpdateUser# has completed the following training: <br>
      <br>
      Class:&nbsp; <b>#getClassDetail.course_name#</b> <br>
      Date:&nbsp; <b>#DateCompleted#</b> <br>
      Due Date:&nbsp; <b>#LSDateFormat(getClassDetail.date,'MM/DD/YYYY')#</b> <br>
      <br/>
      **The training information was entered by #form.UpdateUser# on #form.UpdateDate# **
    </cfmail>
  </cfif>
</cfif>
<!--- FORM ACTION CODE ENDS HERE --->
<cfif isDefined("QueryType")>
  <div style="text-align:left;">
    <form class="training">
      <fieldset>
      <legend> <cfoutput>#getClassDetail.course_name#
        <cfif getClassDetail.Description EQ ''>
          <cfelse>
          | #getClassDetail.Description#
        </cfif>
      </cfoutput> </legend>
      <ul>
        <li>
          <label>Training Recorded by:</label>
          <input type="text" value="<cfoutput>#FORM.UpdateUser#</cfoutput>" readonly="true" size="30" style="border: medium none; margin-top:4px;" />
        </li>
        <li>
          <label>Training Recorded on:</label>
          <input type="text" value="<cfoutput>#FORM.UpdateDate#</cfoutput>" readonly="true" size="30" style="border: medium none; margin-top:4px;" />
        </li>
        <li>
          <label>&nbsp;</label>
          &nbsp;</li>
        <cfif isDefined("ExpirationDate")>
          <li>
            <label>Expiration Date:</label>
            <input type="text" value="<cfoutput>#ExpirationDate#</cfoutput>" readonly="true" size="30" style="border: medium none; margin-top:4px;"/>
          </li>
        </cfif>
        <li>
          <label>&nbsp;</label>
          &nbsp;</li>
        <li>
          <label>&nbsp;</label>
          &nbsp;</li>
        <li>
          <label>&nbsp;</label>
          &nbsp;</li>
      </ul>
      </fieldset>
    </form>
  </div>
</cfif>
</body>
</html>

Open in new window

0
rrattie
Asked:
rrattie
  • 4
  • 3
1 Solution
 
gdemariaCommented:
I'm not sure if this is your problem or not, but you are creating the directory (if it doesn't exist) AFTER you are using it...

    <cfif DirectoryExists('currentDirectory')>
      <!--- If TRUE --->
      <cffile action="UPLOAD" filefield="FORM.uploadfile#i#" destination="#currentDirectory#\" nameconflict="overwrite" accept="application/msword, application/pdf, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.openxmlformats-officedocument.presentationml.presentation, application/rtf, image/gif, image/jpeg, image/tiff, image/bmp, text/plain">
      <cffile action="rename"  source="#currentDirectory#\#cffile.serverFile#" destination="#currentDirectory#\#getClassDetail.course_name#_#getClassDetail.date#.pdf" attributes="normal"/>
      <cfelse>
      <!---IF NOT TRUE--->
      <cffile action="UPLOAD" filefield="FORM.uploadfile#i#" destination="#currentDirectory#\" nameconflict="overwrite" accept="application/msword, application/pdf, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.openxmlformats-officedocument.presentationml.presentation, application/rtf, image/gif, image/jpeg, image/tiff, image/bmp, text/plain">
      <cffile action="rename"  source="#currentDirectory#\#cffile.serverFile#" destination="#currentDirectory#\#getClassDetail.course_name#_#getClassDetail.date#.pdf" attributes="normal"/>
      <cfdirectory action = "create" directory = "#currentDirectory#">
    </cfif>


Also, note you have to remove the quotes from around currentDirectory, it's looking for a directory called currentDirectory

    <cfif NOT DirectoryExists('currentDirectory')>  <=== remove quotes

Seems it should be...

<cfif NOT DirectoryExists(currentDirectory)>
        <cfdirectory action = "create" directory = "#currentDirectory#">
    </cfif>

    <cffile action="UPLOAD" filefield="FORM.uploadfile#i#" destination="#currentDirectory#\" nameconflict="overwrite" accept="application/msword, application/pdf, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.openxmlformats-officedocument.presentationml.presentation, application/rtf, image/gif, image/jpeg, image/tiff, image/bmp, text/plain">
    <cffile action="rename"  source="#currentDirectory#\#cffile.serverFile#" destination="#currentDirectory#\#getClassDetail.course_name#_#getClassDetail.date#.pdf" attributes="normal"/>

Open in new window

0
 
gdemariaCommented:
I suspect "greater than empty" probably works, but I think this could be tweaked...

  <cfif isdefined("FORM.uploadfile"&i) and FORM["uploadfile"&i] GT "" >


Should be..

  <cfif isdefined("FORM.uploadfile"&i) and FORM["uploadfile"&i] is not "" >

or...

  <cfif isdefined("FORM.uploadfile"&i) and len(FORM["uploadfile"&i])>

0
 
gdemariaCommented:

based on the erorr message, about "destination" being invalid in CFFILE, you may have a bad value in that variable or
in the variable: currentDirectory or  in getClassDetail.course_name


Note that there are a bunch of characters that you can use in the name of a course that you cannot use in the name of a file.  Characters such as , ' /

My suggestion would be to use the course_ID, along with the time stamp, to save the file rather than the course name.  That will save you a lot of headaches.  When you deliver the file back to the user, you can always specify whatever name you want, they don't need to know how it's stored.

Same with the class date field, make sure it's very basic such as YYYYMMDD, no commas, no spaces, etc.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
rrattieAuthor Commented:
Well I tried both suggestions separately and then together, no luck. Still getting the same error.
0
 
gdemariaCommented:
which suggestions?  I made more than two..

How about adding an output statement so we can see what values it's trying to use.

<cfif NOT DirectoryExists(currentDirectory)>
        <cfdirectory action = "create" directory = "#currentDirectory#">
    </cfif>

    <cfoutput>the filename: [#currentDirectory#\#getClassDetail.course_name#_#getClassDetail.date#.pdf]</cfoutput>
    <cfabort>
    
    <cffile action="UPLOAD" filefield="FORM.uploadfile#i#" destination="#currentDirectory#\" nameconflict="overwrite" accept="application/msword, application/pdf, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.openxmlformats-officedocument.presentationml.presentation, application/rtf, image/gif, image/jpeg, image/tiff, image/bmp, text/plain">
    <cffile action="rename"  source="#currentDirectory#\#cffile.serverFile#" destination="#currentDirectory#\#getClassDetail.course_name#_#getClassDetail.date#.pdf" attributes="normal"/>

Open in new window

0
 
rrattieAuthor Commented:
Thanks for the quick and thorough help!
0
 
rrattieAuthor Commented:
It was the #getClassDetail.date#, that column is a datetime column.. I completely forgot, it was sending me a complete date and time string that was killing everything.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now