Jump to content

mass attachment upload


ctech

Recommended Posts

Hello,
i am trying to do a mass attachment upload. looking AdminAttachemnts.php i don't see any database writes? but there is a table with attachement information.

so my question is how does the meta data show up in the database?
once i got this figured out i can ftp upload a bunch of attachments and then write a script to add the meta data to the database...

public function postProcess()
   {
       if (Tools::isSubmit('submitAdd'.$this->table))
       {
           if ($id = intval(Tools::getValue('id_attachment')) AND $a = new Attachment($id))
           {
               $_POST['file'] = $a->file;
               $_POST['mime'] = $a->mime;
           }
           if (!sizeof($this->_errors))
               if (isset($_FILES['file']) AND is_uploaded_file($_FILES['file']['tmp_name']))
               {
                   if ($_FILES['file']['size'] > $this->maxFileSize)
                       $this->_errors[] = $this->l('File too large, maximum size allowed:').' '.($this->maxFileSize/1000).' '.$this->l('kb');
                   else
                   {
                       $uploadDir = dirname(__FILE__).'/../../download/';
                       do $uniqid = sha1(microtime());    while (file_exists($uploadDir.$uniqid));
                       if (!copy($_FILES['file']['tmp_name'], $uploadDir.$uniqid))
                           $this->_errors[] = $this->l('File copy failed');
                       @unlink($_FILES['file']['tmp_name']);
                       $_POST['name_2'] .= '.'.pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
                       $_POST['file'] = $uniqid;
                       $_POST['mime'] = $_FILES['file']['type'];
                   }
               }
           $this->validateRules();
       }
       return parent::postProcess();
   }

Link to comment
Share on other sites

  • 4 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...