?
Solved

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

Posted on 2004-09-08
9
Medium Priority
?
250 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
8 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
How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

 
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

862 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