Adding info to database on image upload.

I am using dropzone.js in my wordpress and it’s working fine. My question is, how can I add image info to my database, like image name, size, dae uploaded, userid who uploaded it.? Here is the upload code, thanks for any help.

function dropzonejs_upload() {

if ( !empty( $_FILES ) && wp_verify_nonce( $_REQUEST[‘my_nonce_field’], ‘protect_content’ ) ) {

$uploaded_bits = wp_upload_bits(
    $_FILES['file']['name'],
    null, //deprecated
    file_get_contents( $_FILES['file']['tmp_name'] )
);

if ( false !== $uploaded_bits['error'] ) {
    $error = $uploaded_bits['error'];
    return add_action( 'admin_notices', function() use ( $error ) {
            $msg[] = '<div class="error"><p>';
            $msg[] = '<strong>DropzoneJS & WordPress</strong>: ';
            $msg[] = sprintf( __( 'wp_upload_bits failed,  error: "<strong>%s</strong>' ), $error );
            $msg[] = '</p></div>';
            echo implode( PHP_EOL, $msg );
        } );
}
$uploaded_file     = $uploaded_bits['file'];
$uploaded_url      = $uploaded_bits['url'];
$uploaded_filetype = wp_check_filetype( basename( $uploaded_bits['file'] ), null );

/*
etc ...
*/

}
die();
}

Any help id appreciated.

Sponsor our Newsletter | Privacy Policy | Terms of Service