View Full Version : changing the name of the file being uploaded

02-10-2003, 04:38 AM
Hi, I am trying to edit a shopping cart named Oscommerce. Maybe some of you know it, maybe not. Regardless, there is an area in the admin that allows you to upload pics. problem is, when you upload it, you can overwrite an old pic with the same name.

someone suggested a time stamp. like when it uploads it tells the date, month, year, maybe even the time.

instead of


it would be


that way it won't have any repeats. problem again is that it's a strange code. can anyone help me out?

02-10-2003, 05:33 AM
As much as we would love to be able to automatically know every line of code of every program ever written in PHP ,it would be easier for us to help you if you posted the relevant section of code from your program. :cool:

02-10-2003, 06:09 AM
but if i did that, things would be oh so much easier. where's the fun in that?

sorry, i guess my brain went on vacation.

here is the part where i think it constrols that area.

// we have an incoming file (temp.zip) in $file
// create stamp
$now = date("m-d-Y\_H.i.s");
// merge
$stamped_file = $now . '-' . $products_pair;

//above is the part i'm trying to add, bellow is the code that works

// copy image only if modified
$products_file= tep_get_uploaded_file('products_file');
$mem_file_directory = tep_get_local_path(DIR_FS_CATALOG_MEM_FILE);

if (is_uploaded_file($products_file['tmp_name'])) {
tep_copy_uploaded_file($products_file, $mem_file_directory);
$products_file_name = $products_pair['name'];

} else {
$products_file_name = $HTTP_POST_VARS['products_previous_file'];

also, i realize that if the file size is large, chances are, the file won't upload. it'll go like it's uploading, but it never reaches. what could cause that?