Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Image Time Stamp


Trusten

Recommended Posts

http://www.oscommerce.com/community/contributions,963

 

 

Often times, if you have an old image on the shop, and you upload a new one that has the same name, osc will overwrite the image. We can't always remember the names of all of our images.

 

this little feature will simply put a time stamp on it. All images will have a different date on it, it won't repeat. it saves up to the very second.

 

instead of pic1.jpg

 

it reads

 

M-D-T-pic1.jpg

 

M-D-T (month day time)

 

 

Many thanks to Galen who took the hour out to help me figure out why it wouldn't work. I owe him coffee....

 

Trusten....

 

 

here is the code

 

In:



catalog/admin/categories.php





Find:



// copy image only if modified

     $products_image = tep_get_uploaded_file('products_image');

     $image_directory = tep_get_local_path(DIR_FS_CATALOG_IMAGES);



     if (is_uploaded_file($products_image['tmp_name'])) {

       tep_copy_uploaded_file($products_image, $image_directory);

       $products_image_name = $products_image['name'];





Replace with:





// copy image only if modified

     $products_image = tep_get_uploaded_file('products_image');

     



// we have an incoming file (temp.zip) in $file

// create stamp

   $now = date("m-d-Y_H.i.s");

 // merge

    $stamped_file = $now . '-' . $products_image['name'];



           $products_image['name'] = $stamped_file; 



     

     $image_directory = tep_get_local_path(DIR_FS_CATALOG_IMAGES);



     if (is_uploaded_file($products_image['tmp_name'])) {

       tep_copy_uploaded_file($products_image, $image_directory);

       $products_image_name = $products_image['name'];   









Thanks to galen for figuring out what was wrong with the code. Have fun.

Link to comment
Share on other sites

// we have an incoming file (temp.zip) in $file

// create stamp

   $now = date("m-d-Y_H.i.s");

 // merge

    $stamped_file = $now . '-' . $products_image['name'];

 

Dejavu.... ;)

 

 

Mattice

"Politics is the art of preventing people from taking part in affairs which properly concern them"

Link to comment
Share on other sites

  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...