Quantcast
Channel: Adobe Community: Message List - ColdFusion
Viewing all articles
Browse latest Browse all 21760

cffile rename -- negating cffile upload makeunique

$
0
0

Hello, to all.

 

I am having a confusing situation occurring when I am working with two cffile processes. The second cffile(rename) negates the first cffile(upload) makeunique attribute.

 

I will try to explain and then provide a copy of my code.

 

The first cffile process uploads a file to a given folder and if the files does exists, adds a sequential number to the end to make it unique, which is what is expected. Right after this cffile(upload) process I capture the uploaded file name with #cffile.serverfile# and then perform a  lcase(replace("#cffile.serverfile#"," ","_","ALL")) to replace spaces with underscores and convert characters to lower case. All is functioning as expected at is point in the process.

 

I then insert the second cffile(rename) renaming the original uploaded file with the new lcase(replace) converted file and this is where the weirdness begins. On the first process of uploading a file, process completes as expected and the file in the folder is now the converted file. However, any subsequent uploads of the same file, negates the makeunique attribute of the first cffile(upload) and simply overwrites the one there, thus no matter how many times I load the same file I only end up with one file, not several files with numercial sequential numbering in place. I know the file showing in the folder is a new file, from the timestamp on the file.

 

Am I just confused on the expectations of the cffile(upload) makeunique and cffile(rename) function? Am I missing a step in making this work properly.

 

Below is the code I have at this point:

 

Thanks in advance -- Leonard

 

= = = My current code = = =

 

<cfif isDefined('form.ButtonUpload')>

 

    <!-- Upload employment application if present -->

    <cfif form.UploadEmploymentApplication neq "">

 

      <cffile action="upload"

      filefield="UploadEmploymentApplication"

      nameconflict="makeunique"

      accept="

        application/msword

      , application/pdf

      , application/vnd.ms-excel

      , application/vnd.openxmlformats-officedocument.wordprocessingml.docume nt

      , application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"

      destination="C:\inetpub\wwwroot\monroefire\resources\employment_oppor tunities" >

 

      <cfset OriginalApplicationFile = "#cffile.serverfile#">

      <cfset NewApplicationFile = lcase(replace("#cffile.serverfile#"," ","_","ALL"))>

 

      <cffile action = "rename"

      source = "C:\inetpub\wwwroot\monroefire\resources\employment_opportunities\#Or iginalApplicationFile#"

      destination = "C:\inetpub\wwwroot\monroefire\resources\employment_opportunities\#Ne wApplicationFile#" >

 

      <p>Orginal Application File -- <cfoutput>#OriginalApplicationFile#</cfoutput></p>

      <p>New Application File -- <cfoutput>#NewApplicationFile#</cfoutput></p>

 

    </cfif>

 

  <p>Done</p>

 

<cfelse>

 

<p><cfform action="#cgi.script_name#" method="post" enctype="multipart/form-data" name="Form01" preloader="no" id="Form01" lang="en" dir="ltr">

<p><cfinput type="file" name="UploadEmploymentApplication" id="UploadEmploymentApplication" dir="ltr" lang="en"></p>

<p><cfinput type="submit" name="ButtonUpload" id="ButtonUpload" dir="ltr" lang="en" value="UPLOAD"></p>

<p><cfinput type="submit" name="ButtonResetUpload" id="ButtonResetUpload" dir="ltr" lang="en" value="CLEAR"></p>

</cfform></p>

 

</cfif>


Viewing all articles
Browse latest Browse all 21760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>