Can’t upload a file using wordpress upload functions

Solution 1:

Right-click on this file and then select View/Edit to open wp-config.php in your default text editor. You can then find the following line:

/* That’s all, stop editing. Happy blogging. */”. 

Immediately above this line, copy and paste the below code:

define('ALLOW_UNFILTERED_UPLOADS', true);

Solution 2:

Inside functions.php, add the below code, being sure to update the code to include all of your desired file types:

function my_custom_mime_types( $mimes ) {
 
// Examples of new allowed mime types.
$mimes['svgz'] = 'image/svg+xml';
$mimes['svg'] = 'image/svg+xml';
 
return $mimes;
}
add_filter( 'upload_mimes', 'my_custom_mime_types' );

Solution 3:

Please make sure that your upload form is not inside another form. Because once I got the same error as yours and the problem is because my upload form located inside another form.

Hope this can help.

[updated]

Your form is fine, but I see that the input field name and the post variable name that you catch is different

$uploadedfile = $_FILES['file'];

<input type="file" name="editfile" id="file">

Those names must not be different. Try to edit it like this

$uploadedfile = $_FILES['editfile'];

[updated]

And also please add this to your form’s attribute

enctype="multipart/form-data"

Solution 4:

Use the File Upload Types Plugin