1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

AdminCP - AutoValidator and Uploadunit

Discussion in 'XenForo Development Discussions' started by Snog, May 23, 2016.

  1. Snog

    Snog Well-Known Member

    I have an application where I need to upload a file in the admincp for a new database entry. It all works fine using uploadunit until I place the AutoValidator class into the form that the uploadunit is in.

    I believe I need the AutoValidator and data-redirect = "on" in the template to show the success message when the record is created. But when the AutoValidator class is in the template, the file upload does not take place.

    Any ideas how to display the success message without AutoValidator?
  2. Chris D

    Chris D XenForo Developer Staff Member

    It's not really possible to upload files and use the AutoValidator class. Using the AutoValidator class submits the form over AJAX and there's nothing in the XF code by default that can handle receiving a file using AJAX.

    There's sort of workarounds you can do. For example, look into how the avatar upload overlay works in the front end.

    Other than that, the easiest thing to do is just forego the submission over AJAX.
    Snog likes this.
  3. Snog

    Snog Well-Known Member

    Thanks Chris.

    I had a feeling that was the case when I did a little searching and realized that you couldn't upload an avatar when creating a new user. You have to wait until after the user is created to do it. This would be along similar lines.
  4. Jake B.

    Jake B. Well-Known Member

    We ended up figuring out a workaround for this. We have the file upload as soon as it's selected in the uploader via AJAX, and assign a unique hash to it, then after the form is submitted we associate that hash with the content id. Kinda like the XF attachment system does :)

Share This Page