My Account

Forums

Home Forums General File upload meta_value serialized

Viewing 2 reply threads
  • Author
    Posts
    • #48243
      Tim Littley
      Participant

      I am looking to query the path/name of (public) uploaded files. It appears that the data for this is stored as a (PHP) serialized array.

      Example:

      a:1:{i:0;a:6:{s:4:”name”;s:47:”thumbnail-canmandawe-ftTsK4QinMw-unsplash-1.png”;s:4:”size”;i:1988991;s:4:”type”;s:9:”image/png”;s:13:”attachment_id”;i:1125;s:4:”path”;s:92:”ws-form/1/633d7d1bd95651caf5e54fa0ccdf9f4f/1/thumbnail-canmandawe-ftTsK4QinMw-unsplash-1.png”;s:7:”handler”;s:12:”wsformpublic”;}}

      Does wsform store a clean path/name somewhere? (i.e. “ws-form/1/633d7d1bd95651caf5e54fa0ccdf9f4f/1/thumbnail-canmandawe-ftTsK4QinMw-unsplash-1.png” from the example above?

      Thanks, Tim

    • #48360
      Tim Littley
      Participant

      Okay, I put together a rudimentary sql query to peel away the link, this is obviously a more expensive solution.

      carbon

      This will get you /wp-content/uploads/{path/name}.

      Any thoughts on adding a clean path/name to sql table/column, for public files?

      (BTW the code tags are not protecting sql so had to make a picture instead).

      Tim

    • #48365
      Mark Westguard
      Keymaster

      Hi Tim

      You are correct that the file data is stored in a serialized array. There is no raw version of the filename available in the database. You would need to deserialize the data first using the PHP and then extract the filename from the array element called ‘path’.

      Thanks

      Mark

Viewing 2 reply threads
  • You must be logged in to reply to this topic.

Login