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 Feb 12, 2016, 08:02 AM
    Yes, the upload queue is stored in the MODX session. The queue is there for handling the uploaded files until the form is posted.

    After a form post, the files are moved to the ajaxuploadTarget with the AjaxUpload2Formit hook.

    If the ajaxuploadFieldname field is filled with a comma separated list of filenames and those files exist in ajaxuploadTarget, the upload queue is filled with Formit2AjaxUpload hook when the form page is shown.


    When I edit the form after 4 hours or after the user logout, the queue exists but cannot see thumbnails. So the user cannot remove images since there are no thumbnails, only add images (if it is not violating the maximum number). Queue exists but without thumbnails...

    I assumed that extending the time period that files are remaining at cache folder would solve the problem.
    • The queue should be emptied with 1.4.1, if the image is not found. Before this version, a bug occured.
        • 11121
        • 79 Posts
        Jako when I upload one image I see those files in AjaxUpload cache folder:



        Is this correct? 4 files? The small one is for the thumbnail and the other is the original copy of the file. But why are two copies of each one? [ed. note: gordonas last edited this post 8 years, 2 months ago.]
          • 36549
          • 572 Posts
          Hi,
          Where can i change the 'UPLOAD' text and the class on the button?
            www.9thwave.co.uk
               WEB | DESIGN | PRINT
            • 52289
            • 1 Posts
            Hello,
            I'm using AjaxUpload with Formit+AjaxForm to send Contact form via ajax. Now I need to send form with attachments, i'm using AjaxUpload hooks, but is need another one, which will to remove uploaded files after send mail (hook which starts after mail hook). Could you add it or explain me how to remove all uploaded files?
            • Create a new hook snippet on base of https://github.com/Jako/AjaxUpload/blob/master/core/components/ajaxupload/elements/snippets/ajaxuploadattachments.snippet.php

              Name it AjaxUploadAttachmentsDelete and replace the part:
              $hook->modx->getService('mail', 'mail.modPHPMailer');
              
              foreach ($attachments as $attachment) {
                  $attachment = substr($attachment, $assetsUrlLength);
                  $hook->modx->mail->mailer->AddAttachment($assetsPath . $attachment);
              }

              with:
              foreach ($attachments as $attachment) {
                  $attachment = substr($attachment, $assetsUrlLength);
                  if (file_exists($assetsPath . $attachment)) {
                      unlink($assetsPath . $attachment);
                  }
              }

              and call AjaxUploadAttachmentsDelete after the email hook.

              Untested. Please test it and leave a note, if it is successful.
              [ed. note: Jako last edited this post 7 years, 8 months ago.]
                • 36448
                • 58 Posts
                Hi Jako, Thanks for this script!
                Unfortunately the $attachment start with a slash and file_exists found the files only if I remove this first slash from the $attachment.
                  • 52629
                  • 2 Posts
                  Hello,


                  I am trying to use AjaxUpload in my code but the files are not getting saved in desired directory. Hear is the piece of code

                  [[!Formit?
                  &preHooks=`Formit2AjaxUpload`
                  &hooks=`AjaxUpload2Formit`
                  &ajaxuploadFieldname=`image`
                  &ajaxuploadTarget=`images/uploads/`
                  &ajaxuploadUid=`image`
                  ]]


                  <form action="[[~[[*id]]]]" method="post" class="form">
                  [[!AjaxUpload?
                  &uid=`image`
                  &allowedExtensions=`jpg,jpeg,png,gif`
                  &thumbX=`75`
                  &thumbY=`75`
                  ]]

                  <br class="clear" />

                  <div class="form-buttons">
                  <input type="submit" value="Save" />
                  </div>
                  </form>

                  When I upload the file it shows me in /assets/components/ajaxupload/cache but my image files are not getting saved in desired directory when I hit the save button.
                  Can anyone help me out with this.

                  Thanks in advance.
                  • Quote from: krischel at Jul 05, 2016, 06:38 PM
                    Hi Jako, Thanks for this script!
                    Unfortunately the $attachment start with a slash and file_exists found the files only if I remove this first slash from the $attachment.

                    I have modified my code above a bit ($assetsUrl is stripped and replaced with $assetsPath). It should work now.
                    • Quote from: priya1711 at Aug 12, 2016, 06:18 AM

                      When I upload the file it shows me in /assets/components/ajaxupload/cache but my image files are not getting saved in desired directory when I hit the save button.

                      Does the folder /assets/images/uploads/ exist and is it writable for PHP?