user1049961
user1049961

Reputation: 2736

Pass file to Wordpress wp_handle_upload

I'm trying to pass file to Wordpress wp_handle_upload. Normally it should get $_FILES array, so I tried to create it manually, like

$uploadedfile = array ( 'filePhoto' => array ( 'name' => $name, 'type' => 'image/png', 'tmp_name' => $file, 'error' => 0, 'size' => 178890, ), );
$upload_overrides = array( 'test_form' => false );
$movefile = wp_handle_upload( $uploadedfile, $upload_overrides );

But the file for some reason isn't copied to uploads directory. Any hints?

Thanks

Upvotes: 0

Views: 961

Answers (1)

Alex Weber
Alex Weber

Reputation: 2186

What you want is wp_handle_sideload

upload is only for actual uploads! :)

Upvotes: 1

Related Questions