Jump to content

unlink images


greg

Recommended Posts

I have the following function to delete the product’s images. I want to add the code to delete a hires image located in the folder /hires/ however I can’t get it work.

 

The path for the hires images is www.mysite.com/hires/190.jpg  where 190 is the product_id.

 

Thanks

 

 

function tep_remove_product($product_id)
  {
    $product_image_query = tep_db_query("select products_image from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product_id . "'");
    $product_image = tep_db_fetch_array($product_image_query);

    $duplicate_image_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " where products_image = '" . tep_db_input($product_image['products_image']) . "'");
    $duplicate_image = tep_db_fetch_array($duplicate_image_query);

    if ($duplicate_image['total'] < 2)
	{
      if (file_exists(DIR_FS_CATALOG_IMAGES . $product_image['products_image']))
	  {
        $LargeImage = substr($product_image['products_image'], 0, -4);
        $LargeImageExt = $LargeImage . '.' . 'jpg';
           if (file_exists(DIR_FS_CATALOG_IMAGES . $LargeImageExt))
		  {
		    @unlink(DIR_FS_CATALOG_IMAGES . $LargeImageExt); 
	        }
         @unlink(DIR_FS_CATALOG_IMAGES . $product_image['products_image']); 
        }
      }

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.