Jump to content

[SOLVED] Temporary image import files in /img/tmp


Recommended Posts

I found a lot of files in the /img/tmp folder with the following names :

ps_import05UQTL
ps_import06doUG
.
.
.

Probably these are the temporary image files that are created during import/resizing/etc.
Can these be deleted?
And why arent these deleted after import ?

A default install of prestashop has no files in the /img/tmp dir.
From that i conclude i can delete all files except the index.php

Link to comment
Share on other sites

That's correct. You can delete all files in /img/tmp except for index.php. You may have found another bug in the import, unless the import script timed out on your site and didn't get the chance to clean up its temporary files.

Link to comment
Share on other sites

I found this function in the AdminTab Class : (line 708)

protected function uploadImage

This apparently deletes the temporary file here :

if ($this->afterImageUpload())
               {
                   unlink($tmpName);
                   return true;
               }



Now i wonder if this function is called when performing an csv import

Link to comment
Share on other sites

I found a solution to the temporary import files.
I have added another php delete command (unlink) to the code in the AdminImport.php file.

File : /admin/tabs/AdminImport.php
Line : 389-404
Old code

if (@copy($url, $tmpfile))
       {
           deleteImage($id_entity,$id_image);
           imageResize($tmpfile, $path.'.jpg');
           $imagesTypes = ImageType::getImagesTypes($entity);
           foreach ($imagesTypes AS $k => $imageType)
               imageResize($tmpfile, $path.'-'.stripslashes($imageType['name']).'.jpg', $imageType['width'], $imageType['height']);
       }
       else
       {
           unlink($tmpfile);
           return false;
       }
       return true;
   }    



New code :

if (@copy($url, $tmpfile))
       {
           deleteImage($id_entity,$id_image);
           imageResize($tmpfile, $path.'.jpg');
           $imagesTypes = ImageType::getImagesTypes($entity);
           foreach ($imagesTypes AS $k => $imageType)
               imageResize($tmpfile, $path.'-'.stripslashes($imageType['name']).'.jpg', $imageType['width'], $imageType['height']);
       }
       else
       {
           unlink($tmpfile);
           return false;
       }
       unlink($tmpfile);
       return true;
   }    

Link to comment
Share on other sites

  • 3 years later...

I found a solution to the temporary import files.

I have added another php delete command (unlink) to the code in the AdminImport.php file.

 

File : /admin/tabs/AdminImport.php

Line : 389-404

Old code

if (@copy($url, $tmpfile))        {            deleteImage($id_entity,$id_image);            imageResize($tmpfile, $path.'.jpg');            $imagesTypes = ImageType::getImagesTypes($entity);            foreach ($imagesTypes AS $k => $imageType)                imageResize($tmpfile, $path.'-'.stripslashes($imageType['name']).'.jpg', $imageType['width'], $imageType['height']);        }        else        {            unlink($tmpfile);            return false;        }        return true;    }

New code :

if (@copy($url, $tmpfile))        {            deleteImage($id_entity,$id_image);            imageResize($tmpfile, $path.'.jpg');            $imagesTypes = ImageType::getImagesTypes($entity);            foreach ($imagesTypes AS $k => $imageType)                imageResize($tmpfile, $path.'-'.stripslashes($imageType['name']).'.jpg', $imageType['width'], $imageType['height']);        }        else        {            unlink($tmpfile);            return false;        }        unlink($tmpfile);        return true;    }

 

Hi,  I have the latest prestashop version 1.5.6.1.  I don't see the files that you mentioned here.  Did this code resolved your issue?

 

What was the solution you found out regarding tmp files?  Please help! 

Link to comment
Share on other sites

  • 8 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...