• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Deleting Images without using cfdirectory

Explorer ,
Sep 26, 2006 Sep 26, 2006

Copy link to clipboard

Copied

All my stuff is obviously stored in a database, and I am outputting it. Along with that is the link for an image which is on the server. When I go to my page to delete entries from the database, it does not delete the image. I know I can do this with a form using cfdirectory, but there is no way for me to link the two as far as I know. How can I say parse the link from the database to get the filename only, so after the news/xxxx.extension and then I can send that to the query to do cffile delete. Any help would be great!

I hope that made sense though. If not post something and I can rephrase it and maybe throw some code in.
TOPICS
Advanced techniques

Views

315

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Sep 26, 2006 Sep 26, 2006
Use listlast on the column, this will give you the file name.

<cfset theFile = ListLast("www.yahoo.com/uploads/thisismyimage.gif", "/")>

Ken

Votes

Translate

Translate
Engaged ,
Sep 26, 2006 Sep 26, 2006

Copy link to clipboard

Copied

you can't delete the actual file with a query. you must use <cffile action="delete" ...> tag. look up doc on cffile to see how to use it with the delete action.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 26, 2006 Sep 26, 2006

Copy link to clipboard

Copied

quote:

Originally posted by: Sabaidee
you can't delete the actual file with a query. you must use <cffile action="delete" ...> tag. look up doc on cffile to see how to use it with the delete action.


I know that. I am saying that I am outputting the information from the database with a query. When I delete it, you click a button, and it already deletes the information from the table. The part I do not know how to do is extract the filename from the field in the database.

For example, in the database news, there is a row called image. In the image field it is www.yahoo.com/uploads/thisismyimage.gif. I want to be able to pull the thisismyimage.gif out of that so when I run the cffile delete query it can delete that file from the directory.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 26, 2006 Sep 26, 2006

Copy link to clipboard

Copied

Use listlast on the column, this will give you the file name.

<cfset theFile = ListLast("www.yahoo.com/uploads/thisismyimage.gif", "/")>

Ken

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 26, 2006 Sep 26, 2006

Copy link to clipboard

Copied

LATEST
Awesome. That works great!

Really appreciate it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation