Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2005
    Location
    Chicago, IL USA
    Posts
    1,557
    Plugin Contributions
    28

    Default Attribute file upload bug if too many periods in filename?

    In Zen Cart 1.5.7, a file uploaded with an order as an attribute is accessible via the admin. Very nice addition!!

    But if the file uploaded contains a period in the file name, it cannot be downloaded. The file exists on the server so is uploaded properly.

    To 'fix' this, I edited /ADMIN/includes/functions/general.php line 3847
    It was:
    return $filenum . "." . $filetype;

    it is now:
    return $filenum . "." . pathinfo($filename, PATHINFO_EXTENSION);

  2. #2
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Attribute file upload bug if too many periods in filename?

    May I suggest perhaps changing line 3846 as below:
    Code:
      function zen_get_uploaded_file($filename) {3842
        global $db; 
        $parts = explode(". ", $filename, 2);
        $filenum = $parts[0];
        $filename = $parts[1]; 
        $file_parts = explode(".", $filename, 2);
        $filetype = $file_parts[sizeof($file_parts) - 1]; 
        return $filenum . "." . $filetype; 
      }
    Code:
      function zen_get_uploaded_file($filename) {3842
        global $db; 
        $parts = explode(". ", $filename, 2);
        $filenum = $parts[0];
        $filename = $parts[1]; 
        $file_parts = explode(".", $filename);
        $filetype = $file_parts[sizeof($file_parts) - 1]; 
        return $filenum . "." . $filetype; 
      }
    from
    Code:
    $file_parts = explode(".", $filename, 2);
    to
    Code:
    $file_parts = explode(".", $filename);
    Or if necessary just change the assignment of $filetype using the above suggested code. This would then look like:
    Code:
      function zen_get_uploaded_file($filename) {3842
        global $db; 
        $parts = explode(". ", $filename, 2);
        $filenum = $parts[0];
        $filename = $parts[1]; 
        //$file_parts = explode(".", $filename);
        $filetype = pathinfo($filename, PATHINFO_EXTENSION); 
        return $filenum . "." . $filetype; 
      }
    $fileparts becomes unnecessary when pathinfo is used, though one interesting thing about attempting to use that function is that it seems that the filesystem in some way is accessed because when I try to use that function on a publicly available php site, they say they have disabled the function for security purposes...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. Thumbnail Preview of file after upload via Attribute File uploader?
    By NWFAP in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 7 Aug 2015, 03:40 AM
  2. Too many items in cart? Or is it too many attributes?
    By CabinetGuy in forum Managing Customers and Orders
    Replies: 16
    Last Post: 23 Aug 2011, 07:13 PM
  3. After file upload, want to make filename a clickable link to preview uploaded content
    By PaulRiedel in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 3 Feb 2010, 03:17 PM
  4. Too many queries were running? -- a bug?
    By doubletiger in forum General Questions
    Replies: 6
    Last Post: 17 Nov 2006, 10:53 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR