Trying to make a form to upload an image to Wordpress, then set that image as a post's thumbnail. But I can't seem to get the media_handle_upload() function to work properly.
the form's input for the file
<input type="file" name="image" />
then this is the server side code
media_handle_upload( $_FILES['image'], 22 );
and this is what I get returned
object(WP_Error)#212 (2) { ["errors"]=> array(1) { ["upload_error"]=> array(1) { [0]=> string(212) "File is empty...." } } ["error_data"]=> array(0) { } }
I have played around with a couple different ways to enter the file variable,but none seems to work, am I doing that from, what exactly is the $file_id;