I have a function wp_handle_upload() for uploads files.
$file = $_FILES['attachment_icon-' . $i];
$upload = wp_handle_upload($file, array('test_form' => false));
what is a function for delete a uploaded file?
2 Answers
Use wp_delete_attachment( $post_id )
if you have used wp_insert_attachment()
before.
$post_id
is the attachment ID.
If you haven’t used wp_insert_attachment()
a simple …
unlink( $upload['file'] );
… will do it.