Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CFFILE delete - file name has pound sign, cannot delete it

Posted on 2004-09-08
9
Medium Priority
?
249 Views
Last Modified: 2013-12-24
I am trying to delete a file that had been previously uploaded.  Code works fine until the user uploaded a file with a '#' in the file name i.e. test#2.txt.  Am getting an error message:

Unable to delete the file '\\xxxxxx\test.' The system cannot find the file specified. (error 2)

<cfparam name="file_name_delete" default="">

<cffile action="DELETE" file= "#Replace(dest_path,"##","####","All")#\#Replace(file_name_delete,"##","####","All")#">

The parameter is being passed in from the same template as follows:

<a href="xxxxx.cfm?app_id=#app_id#&attachment_id_delete=#qry_attachment.attachment_id#&file_name_delete=#Replace(qry_attachment.file_name,"##","####","All")#" class="StdTextLink">Delete</a>

Seems that I am not able to use the replace command withing the cffile tag - any suggestions as to how to work around this?

thanks very much!
0
Comment
Question by:jennilee13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 17

Expert Comment

by:Tacobell777
ID: 12011380
Have you tried just hardcoding the full path to see if you have the right path?
<cffile action="DELETE" file="c:\path\test##2.txt">


Or do a <cfset myPath = Replace(dest_path,"##","####","All") & "\" &Replace(file_name_delete,"##","####","All")>

then output myPath and see if the generated path is correct.
0
 

Author Comment

by:jennilee13
ID: 12011648
The path is correct as the code works perfectly on files without a "#".  I put in a hard-coded file name with two '#'s in it and the file was deleted correctly.  I tried doing the replace function outside of the cffile delete, as you describe above, still same error message.  I cannot get the 'file' variable in the cffile tag to recognize that there are two ##.  It seems like it is only seeing the first #, no matter what i do!
0
 

Author Comment

by:jennilee13
ID: 12011715
opps, you were correct - it looks like the problem is in passing the file name in upon the submit in the href as the portion of the file name including and after the # is truncated.   So it now seems as if the replace function in the href is not properly adding the additional #?
0
Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

 
LVL 17

Expert Comment

by:Tacobell777
ID: 12012673
hold on, you are getting the file name value from a database right? The when you output it, it should not have to be escaped again, as its a string and not evaluated again..
0
 
LVL 10

Expert Comment

by:Mause
ID: 12015010

Tacobell is right the value of your variable won't be evaluated

so <cffile action="DELETE" file= "#dest_path#\#file_name_delete#"> will be enough

0
 

Author Comment

by:jennilee13
ID: 12017728
Then why is the file name value being truncated after the # sign after the submit?  I am getting the name from a database, it is then displayed on the screen.  The user can then click on the delete button and the value from the db is passed via the href to the same template where there is some logic at the top that decides if the delete action should take place.   I display the value passed right before the cffile funtion and it has been truncated, i am assuming during the processing that takes place when the delete key is clicked and the template is re-loaded?

The code did not contain the replace function previously (i put that in to try to resolve the problem) and had been working for years!  Again, until the dang user decides they want file names with # signs!

uggg!
0
 

Author Comment

by:jennilee13
ID: 12018832
by going through some other web searches finally came up with the solution myself - needed to have the href formatted as
follows:


<a href="xxxxx.cfm?app_id=#app_id#&attachment_id_delete=#qry_attachment.attachment_id#&file_name_delete=#URLEncodedFormat(qry_attachment.file_name)#" class="StdTextLink">Delete</a>

then the cffile tag would be:

<cfparam name="file_name_delete" default="">

<cffile action="DELETE" file= "#dest_path#\#file_name_delete#">

no replace function was required at all.  Can i award myself the points?? :~)

0
 

Accepted Solution

by:
CetusMOD earned 0 total points
ID: 12289311
PAQed, with points refunded (300)

CetusMOD
Community Support Moderator
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

618 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