Skip to content
Advertisement

fix WordPress api failed upload test error

I have created a form which uses ajax to post data to WordPress media using WordPress API. I am receiving the error specified file failed upload test. I’m using the JWT auth plugin for authentication.

ADD A MEDIA FORM

JavaScript

CREATE MEDIA FUNCTION

JavaScript

I could not find a php.ini file on the hosted directory so created a blank file and set file_uploads = on but that didn’t work. I looked in the file wp-admin/includes/file.php but don’t know if anything needs changing. I have checked and there is no other file with the same name in the WordPress media.

UPDATED

Following the user’s advice I commented out enc type and content type and added the last line of the xhr for mp4 and this worked. I amended it with the last two entries for jpg and got a security error. I am trying to add the token details to xhr is this correct and how should it be formatted as I think I have a bracket missing somewhere

JavaScript

Advertisement

Answer

in WordPress add define(‘ALLOW_UNFILTERED_UPLOADS’, true); in the wp-config file. Then change ajax to include xhr function:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement