We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11121
    • 79 Posts
    Quote from: Jako at Jan 06, 2016, 06:25 AM
    If the user edits a resource with a form on the resource itself, the &ajaxuploadUid could be set to i.e. `image[[*id]]`. If you edit all ads on one resource with a form, you have to set it to i.e.`image[[+identifier]]` (identifier could contain the same value that is used to identify the edited ad).


    When I edit the resource second time and after, image[[*id]] indeed it is working. My big problem is when the user creates the resource. At that time there is no resource id to attach to uid, cause the user is at a page which all users are using to upload a resource. There is not a specific id yet for the new resource. I need some [+identifier]].

    I am trying to create that identifier. Obviously must be set as prehook before ajaxupload and saved as a field of the new resource when it's get created.

    But my knowledges are poor at this level and I am stuck. Maybay a timestamp? A unique random number?

    I need it as a prehook and save at the new resource.

    I think this it would be a great addon for Ajaxupload. To have, optional, the ability to give a unique random number to uid.

    Thank you for your fast replies.
      • 13428 ☆ A M B ☆
      • 1,031 Posts
      Each user has its own session. So the temporary files can't be messed up that way. An issue could occur, if the same user opens two windows/tabs creating to create two resources at the same time. Then one upload queue is used for both windows/tabs.

      You could avoid that, if you call the create resource with an unique id as GET parameter, and POST this parameter in a hidden input. Caution for XSS issues. &ajaxuploadUid will be filled with that unique id, i.e. with
      &ajaxuploadUid=`image[[#request.uid:striptags:htmlent]]`

      if you have FastField installed.
        • 11121
        • 79 Posts
        Problem solved. Thank you for the advice!!

        Some new/old problem now. If I create a tv field with the name "PHOTOS", assign it to the resource and put ajaxuploadFieldname="PHOTOS", it will work?

        Or without creating a tv, how I retrieve image paths from given ajaxuploadFieldname, "PHOTOS" in my case? [ed. note: gordonas last edited this post 10 years, 9 months ago.]
          • 13428 ☆ A M B ☆
          • 1,031 Posts
          You should retrieve the comma separated list of file paths in [[!+fi.PHOTOS]] (form chunk), in [[+PHOTOS]] (mail chunk) or in $hook->getValue('PHOTOS') then.
            • 11121
            • 79 Posts
            Quote from: Jako at Jan 18, 2016, 07:58 AM
            You should retrieve the comma separated list of file paths in [[!+fi.PHOTOS]] (form chunk), in [[+PHOTOS]] (mail chunk) or in $hook->getValue('PHOTOS') then.


            Thanx again!

            Something last (for real)... smiley I got the comma seperated list. How I can call part of this list? The second image path for example. I want to make thumbnail of the uploaded images and I need different size for each of them.
              • 13428 ☆ A M B ☆
              • 1,031 Posts
              That has to happen in formit2resource.
                • 49710
                • 92 Posts
                The E-mal contains only a string from the filename. Not the file itself. What can it be?

                [[!FormIt?
                	&preHooks=`Formit2AjaxUpload`
                   &hooks=`AjaxUpload2Formit,AjaxUploadAttachments,email,spam,redirect`
                   &ajaxuploadFieldname=`image`
                	&ajaxuploadTarget=`mscript`
                	&ajaxuploadUid=`image`
                   &emailTpl=`content.man-email`
                   &emailSubject= `Test`
                   &emailTo=`[email protected]`
                   &redirectTo=`17`
                   &validate=`email:email:required,
                			  nachricht,
                			 vorname:required,
                			 strasse:required,
                			 plz:required:isNumber,
                			 ort:required,
                			 name:required`
                   &vTextRequired=`Bitte einen Wert für dieses Feld angeben.`
                  	&subject.vTextRequired=`Bitte einen Wert oder Text eingeben.`
                	&validationErrorMessage=`Formular nicht gesendet, da ein oder mehrere Eingaben nicht vollständig sind.`
                
                
                ]]


                Done!

                &ajaxuploadTarget=`script`
                is better
                &ajaxuploadTarget=`script/` [ed. note: ichris89 last edited this post 10 years, 8 months ago.]
                  • 11121
                  • 79 Posts
                  Quote from: Jako at Jan 19, 2016, 01:18 AM
                  That has to happen in formit2resource.

                  I see. I just realized that files are not uploading to destination folder but only to Ajaxupload cache folder. Files are copied to destination folder immediately or first to cache and after 4 hours to destination folder?

                  This is my setting at Formit call:
                  &ajaxuploadTarget=`uploads/`

                  and this is the setting at core/config/config.inc.php:
                  $modx_assets_url= '/assets/';

                  Also I get this at modx error log:
                  (ERROR @ /index.php) modResource: Attempt to set NOT NULL field template to NULL

                  Is there a way to enable debug for Ajaxupload/Formit? It would help a lot.

                  Thanx Jako for helping. [ed. note: gordonas last edited this post 10 years, 8 months ago.]
                    • 13428 ☆ A M B ☆
                    • 1,031 Posts
                    formit2resource/resource2formit has to move the files from/to the ajaxuploadTarget folder.
                      • 13428 ☆ A M B ☆
                      • 1,031 Posts
                      Quote from: ichris89 at Jan 19, 2016, 02:38 AM
                      The E-mal contains only a string from the filename. Not the file itself. What can it be?

                      Read the docs, please.