Solved

Attribute validation error for tag CFFILE.

Posted on 2011-03-02
7
1,466 Views
Last Modified: 2012-05-11
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
Comment
Question by:rrattie
  • 4
  • 3
7 Comments
 
LVL 39

Expert Comment

by:gdemaria
Comment Utility
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
 
LVL 39

Expert Comment

by:gdemaria
Comment Utility
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
 
LVL 39

Expert Comment

by:gdemaria
Comment Utility

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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 2

Author Comment

by:rrattie
Comment Utility
Well I tried both suggestions separately and then together, no luck. Still getting the same error.
0
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
Comment Utility
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
 
LVL 2

Author Closing Comment

by:rrattie
Comment Utility
Thanks for the quick and thorough help!
0
 
LVL 2

Author Comment

by:rrattie
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now