?
Solved

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

Posted on 2004-09-08
9
Medium Priority
?
247 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

Question has a verified solution.

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

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
What You Need to Know when Searching for a Webhost Provider
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
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…
Suggested Courses
Course of the Month12 days, 13 hours left to enroll

777 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