Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    Earth
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts

    changing the name of the file being uploaded

    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

    pic1.jpg

    it would be

    M-D-Y-pic1.jpg

    that way it won't have any repeats. problem again is that it's a strange code. can anyone help me out?
    Life is funny, especially when you're poor.

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    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.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Location
    Earth
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

    PHP Code:
    // 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_filetep_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?
    Life is funny, especially when you're poor.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •