AdminCP - AutoValidator and Uploadunit

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?
 
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.
 
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.
 
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.

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 :)
 
Back
Top Bottom