1

Is there any method to delete files in magento? I have a custom module using which I can upload images to the folder media. Now I am planning to provide a delete option under each uploaded images(uploaded images will display in my module). When delete option clicked, it should delete images from media folder and its name from the custom table

custom table name : banner
custom field name for storing image names :  images
         (names are separated by commas)
module : custom admin module use to upload multiple images
module model name : banner/banner

Is it really necessary to delete images from media folder. Please provide your suggestions. Thanks in advance

  • Is your question about whether or not it's good policy to clean up images if unused or on how to build an extension like this? – Sander Mangel Jan 15 '14 at 8:34
  • @SanderMangel:yes. exactly. I want to know whether it is essential to delete unused images in magento. However I need to remove the name of unused image from magento – Rajeev K Tomy Jan 16 '14 at 1:04
2

Because Magento is based on PHP, there is a method to delete files: unlink ;-)

Beside of this very basic method I can't find any class in Magento or the attached Zend_Framework which offers a file abstraction.

  • Is magento using unlink for deleting images then? In other words, how unwanted files are manipulating by magento? – Rajeev K Tomy Jan 16 '14 at 1:07
  • In the end? Yes @unlink($fullPath);, /app/code/core/Mage/Core/Model/Resource/File/Storage/File.php:122 but most of the time magento doesn't delete anything, e.g. images from media folder. – Fabian Blechschmidt Jan 16 '14 at 7:00
  • when should we think about deleting images then? which are the specific cases, where deletion is better than leaving the unwanted images? – Rajeev K Tomy Jan 16 '14 at 7:11
  • I only know one case: When you get copyright problems – Fabian Blechschmidt Jan 16 '14 at 7:12
  • :Thanks it will help me a lot. Thanks for your explanation. – Rajeev K Tomy Jan 16 '14 at 7:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.