Admin page: form with enctype=”multipart/form-data” does not transfer its data


I’m googeling for hours now but can’t find anything to my problem:

I’m building a plugin and want to embed a file input in its admin page. For this reason I’m giving the form-element the attribute enctype="multipart/form-data" and I’m trying to access the file via $_FILES, but it is empty!
Same with $_POST.

Without enctype="multipart/form-data" at least the filename and the other form fields appear in $_POST.

I’m wondering if WordPress is removing direct access to these superglobals or somehow else preventing this regular way of uploading files.

I’ve read a lot about hooks and posting all forms to admin_post.php or admin_ajax.php but since my upload functionality is located in a class that’s part of a big library with autoloading etc. it’s not an option for me. My form is sending it’s data to the current admin page (I tried it without the action-Attribute but also specifying it action="admin.php?page=XYZ" but nothing worked).

I would be thankful for every hint!

, , , Robert 8 months 0 Answers 97 views 0

Leave an answer