Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,911
    Plugin Contributions
    96

    Default File-upload attribute question

    I have a product that includes a file-upload attribute; I choose a file and successfully add the associated product to my cart ... the file is uploaded correctly into the /images/uploads directory. If I subsequently delete that product from my cart, shouldn't the file be deleted from /images/uploads?

  2. #2
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,755
    Plugin Contributions
    9

    Default Re: File-upload attribute question

    If I subsequently delete that product from my cart, shouldn't the file be deleted from /images/uploads?
    Is this a file uploaded by a customer??

    If so, then no you must attend to the uploaded files manually
    Zen-Venom Get Bitten

  3. #3
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,911
    Plugin Contributions
    96

    Default Re: File-upload attribute question

    kobra, it doesn't matter whether it's a guest or a customer ... if a product with an associated upload-file is successfully added to the cart and subsequently deleted from the cart, the uploaded file remains.

  4. #4
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,755
    Plugin Contributions
    9

    Default Re: File-upload attribute question

    successfully added to the cart and subsequently deleted from the cart, the uploaded file remains
    Mis read you OP
    But the answer is the same - once uploaded, you must manually attend to them

    Take care as you will receive root kits and other nefarious files being uploaded
    Zen-Venom Get Bitten

  5. #5
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,911
    Plugin Contributions
    96

    Default Re: File-upload attribute question

    Here's an update to the remove function of /includes/classes/shopping_cart.php (v1.5.1) that automatically deletes any uploaded files associated with a product that was deleted from the cart:
    Code:
      /**
       * Method to remove an item from the cart
       *
       * @param mixed product ID of item to remove
       * @return void
       * @global object access to the db object
       */
      function remove($products_id) {
        global $db;
        $this->notify('NOTIFIER_CART_REMOVE_START');
        //die($products_id);
        //CLR 030228 add call zen_get_uprid to correctly format product ids containing quotes
        //      $products_id = zen_get_uprid($products_id, $attributes);
    /*-bof-lat9-BUGFIX-delete uploaded file, if present */
        if (is_array ($this->contents[$products_id]['attributes_values'])) {
          foreach ($this->contents[$products_id]['attributes_values'] as $option_id => $option_value) {
            $sql = "SELECT products_options_type FROM " . TABLE_PRODUCTS_OPTIONS . " WHERE products_options_id = '" . zen_db_input($option_id) . "'";
            $sqlResult = $db->Execute($sql);
    	if (!$sqlResult->EOF && $sqlResult->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_FILE) {
    	  //
    	  //- The value for the file-upload option is of the form "nn. <originalfilename", where nn is the index in the files_uploaded table.
    	  //- The uploaded file is /images/uploads/nn.ext, where ext is the originalfilename's file extension
    	  //
    	  $filename = substr($option_value, 0, strpos($option_value, '.'));
    	  $file_ext = substr($option_value, 0-(strlen($option_value) - strrpos($option_value, '.')));
    	  @unlink (DIR_FS_UPLOADS . $filename . $file_ext);
    	  
    	}  // Current attribute is a file-upload one
          }
        }
    /*-eof-lat9-BUGFIX-delete uploaded file, if present */
        unset($this->contents[$products_id]);
        // remove from database
        if ($_SESSION['customer_id']) {
    
          //        zen_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . zen_db_input($products_id) . "'");
    
          $sql = "delete from " . TABLE_CUSTOMERS_BASKET . "
                    where customers_id = '" . (int)$_SESSION['customer_id'] . "'
                    and products_id = '" . zen_db_input($products_id) . "'";
    
          $db->Execute($sql);
    
          //        zen_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . zen_db_input($products_id) . "'");
    
          $sql = "delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . "
                    where customers_id = '" . (int)$_SESSION['customer_id'] . "'
                    and products_id = '" . zen_db_input($products_id) . "'";
    
          $db->Execute($sql);
    
        }
    
        // assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
        $this->cartID = $this->generate_cart_id();
        $this->notify('NOTIFIER_CART_REMOVE_END');
      }

 

 

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. v139h uploading artwork file (attribute) does not upload file
    By delia in forum General Questions
    Replies: 11
    Last Post: 1 Sep 2013, 08:41 PM
  3. Attribute File Upload
    By timestands in forum Setting Up Categories, Products, Attributes
    Replies: 30
    Last Post: 12 Oct 2011, 09:40 PM
  4. File Upload Attribute - File Size Limit?
    By Genevieve in forum General Questions
    Replies: 2
    Last Post: 4 May 2010, 06:33 PM
  5. upload file attribute
    By mwsebesta in forum Setting Up Categories, Products, Attributes
    Replies: 5
    Last Post: 23 Sep 2009, 09:01 AM

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