How to send custom variable in Media Uploader ajax request?

My first instinct was to find _acfuploader in ACF code to see how they are doing it. Unfortunately the latest version doesn’t seem to have any occurrences of acfuploader.

The second thing I thought of was the wp_get_referer function. You could use it to see where the ajax request came for. Then you could get the post ID from the query string, get the post type and make a decision based on the value you obtained.

However the HTTP referrer can easily be spoofed so you will have to consider the security implications of using it in your code. However, in this scenario the user doesn’t have much to gain from spoofing HTTP referrer so I think it is a viable solution.