Skip to main content
Inspiring
July 27, 2007
Question

cffile issue

  • July 27, 2007
  • 1 reply
  • 239 views
well here is my problem..

i have a checkbox of items to delete, the items are displyed in the action page:

select image from table where
id = <cfqueryparam cf_sql_type="integer" value="#ListLen(form.del_ID,',')#">

ok this gets the file frfom the database..

then i check to see if the directory where the file is residing on my server exists..

if yes..

then i use this command

<cffile action=delete file=#queryname.image#>

and then

i do like this:

new query:

delete from mytable where ID in(#form.del_ID#)

but it deletes the record but does not delete the file from the server..

wel for the clarity of code here it is ;


<cfquery name="gb" datasource="#dsn#">
SELECT image
FROM mytable
WHERE ID = <cfqueryparam cfsqltype="cf_sql_integer" value="#ListLen(form.del_ID,',')#">
</cfquery>
<cfoutput query="gb">
<cfif directoryexists("#Application.file_path#banner")>
<cfset _file = "#Application.file_path#banner">
<cffile action="delete" file="#_file#/#gb.image#">
</cfif>
</cfoutput>
<CFQUERY DATASOURCE="#dsn#">
DELETE from mytable
WHERE ID IN (#form.del_ID#)
</CFQUERY>




#Application.file_path# shows my actual path and i have tested it, its working as

http://mysite.com/www/

i tries this also:

<cffile action="delete"
file="#expandpath("banner/#gb.image#")#">

due to this expandpath hange, i am able to delete the data from the database but the imag file remains in the folder, it still not gets deleted.
This topic has been closed for replies.

1 reply

July 27, 2007
can you post the output of #expandpath("banner/#gb.image#")#?

also, check out the requirements for the 'file' attribute here : http://livedocs.adobe.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=00000248.htm