Results 1 to 2 of 2

Thread: How to manage files implementing processFormData hook?

  1. #1
    New user
    Join Date
    01-30-17.
    Posts
    5

    Default How to manage files implementing processFormData hook?

    Good morning!

    I'm coding a class for using when a form is sent (using processFormData hook). In the form, some files could be uploaded (usually an image file). I configured in the backend that the file uploaded is stored in certain directory. The idea is to generate a news item with this form data.

    I need to know, when hook 'processFormData' is triggered, the singleSRC of the form uploaded file for writing it in tl_news table. What's the easier way?

    I'm trying to get that singleSRC from array $arrFiles, but I don't know how this array works. If it's not possible to directly read the singleSRC, it could be useful to know (at least) the file name (note: in formgenerator (backend) i check the option 'don't overwrite existing files', so probably the system will add a number at the end of the original file name. On that case, I could use something like this (I found it searching...):

    Code:
    			$file = Dbafs::addResource($fileName);
    			$set = Dbafs::syncFiles();
    			$singleSRC = $file->uuid;
    I appreciated any help. Thanks a lot!
    Last edited by infomiquel; 01/30/2017 at 13:13.

  2. #2
    New user
    Join Date
    01-30-17.
    Posts
    5

    Default

    I found it: I get the singleSRC from $arrFiles:

    Code:
    $arrFiles[picture][uuid]
    Explanation:

    Code:
    $arrFiles[name_of_the_form_field][uuid]
    FilesModel->uuid seems to be equivalent to singleSRC.

    Quote Originally Posted by infomiquel View Post
    Good morning!

    I'm coding a class for using when a form is sent (using processFormData hook). In the form, some files could be uploaded (usually an image file). I configured in the backend that the file uploaded is stored in certain directory. The idea is to generate a news item with this form data.

    I need to know, when hook 'processFormData' is triggered, the singleSRC of the form uploaded file for writing it in tl_news table. What's the easier way?

    I'm trying to get that singleSRC from array $arrFiles, but I don't know how this array works. If it's not possible to directly read the singleSRC, it could be useful to know (at least) the file name (note: in formgenerator (backend) i check the option 'don't overwrite existing files', so probably the system will add a number at the end of the original file name. On that case, I could use something like this (I found it searching...):

    Code:
    			$file = Dbafs::addResource($fileName);
    			$set = Dbafs::syncFiles();
    			$singleSRC = $file->uuid;
    I appreciated any help. Thanks a lot!

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
  •