0 users online. Create an account or sign in to join them.Users

Search

Has anybody ever used the XML importer on a section that contains a upload field? I am currently trying to import a couple of files into said section but can't seem to make it work.

My first try consisted of simply passing the filename to the field as if it was a textfield: concat('/uploads/bilder/', filename/text()) as the XPath expression. The data was going to the right MySQL table but it was missing all the metadata (mimetype, size and file creation metadata).

Nick hinted at "the field accepts strings and arrays, maybe try the latter" so I introduced a new function to the importer file and applied it to the upload field values:

        static function makeArray($string) {
        return array(
            'name' => '/uploads/bilder/' . $string,
            'type' => mime_content_type(WORKSPACE . '/uploads/bilder/' . $string),
            'size' => filesize(WORKSPACE . '/uploads/bilder/' . $string),
            'meta' => serialize(fieldUpload::getMetaInfo(WORKSPACE . '/uploads/bilder/' . $file, mime_content_type(WORKSPACE . '/uploads/bilder/' . $string)))
            );
    }

But this failed as the upload field was complaining about the file already existing. Moving all files to a different directory didn't help though.

I tried overriding the uploadfield's "file exists"-check but the data didn't end up in the table at all, not a single line was added.

So my question remains: has anybody tried to import data into upload fields before?

P.S. I'm using the unique upload field but was overriding it's special filename treatment for my experiments.

Did you find a solution?

bzerangue apparently got this to work with the regular upload field this post and the following ones.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details