AjaxUploadRequired does not seem to work


I am using the AjaxUpload package to allow users to upload video files to a folder. Although I have included the AjaxUploadRequired hook, the form can still be submitted without uploading a video, and if the video is in the process of uploading when the submit button is pressed, an alert pops up that just asks the user if they are sure they would like to leave the page because it might cause their form to reset.

Here is the code for my FormIt tag:


And here is my code for AjaxUpload:


Am I using the AjaxUploadRequired hook incorrectly?

I installed AjaxUpload 1.6.3-pl and it seems that the snippet “AjaxUploadRequired” has the wrong content. (In fact the same content as the snippet “AjaxUploadAttachments”.)

Can you confirm that?

Does it work if you replace the content of the snippet “AjaxUploadRequired” with this code?


Thank you for the quick response. Unfortunately I tried replacing the code in my AjaxUpload file but as soon as I replaced it with the code you provided my webpage would not load anymore.

What exactly did you do?

Did you open the snippet “AjaxUploadRequired” in the MODX manager and replace the snippet content with the content from the file core/components/ajaxupload/elements/snippets/ajaxuploadrequired.hook.php?

When I test it, this fixed the issue. (There seems to be a typo in the installation script, so that the snippet “AjaxUploadRequired” gets the content from the wrong file.)

Do you have the current version (1.6.3-pl) of AjaxUpload installed?

I’m sorry, I misread your original post and attempted to replace the “AjaxUpload” snippet rather than the “AjaxUploadRequired” snippet.

When I do replace the “AjaxUploadRequired” snippet with the code from the file that you suggested I am still able to submit my form without uploading anything through AjaxUpload.

When I look at AjaxUpload.php I see that the $version variable is set to '1.6.3', so I believe that I do have the current version installed.

You can always submit the form, but does it send the email?

If you add a property ajaxuploadRequiredMessage, does it show the error message if you don’t upload a video?

    &ajaxuploadRequiredMessage=`Please upload a video!`
<form id="myform" action="[[~[[*id]]]]" method="post">   
   <div class="error">[[!+fi.error.campaign_video]]</div>

The hook AjaxUploadRequired gets executed on the server. So you have to submit the form to run the check. If you want to avoid that the form can be submitted at all, you probably have to write some Javascript code for that.

You can see the version of the installed extras in the menu “Extras” → “Installer”.