get_file_params example

/** * Inserts the attachment post in the database. Does not update the attachment meta. * * @since 5.3.0 * * @param WP_REST_Request $request * @return array|WP_Error */
    protected function insert_attachment( $request ) {
        // Get the file via $_FILES or raw data.         $files   = $request->get_file_params();
        $headers = $request->get_headers();

        if ( ! empty( $files ) ) {
            $file = $this->upload_from_file( $files$headers );
        } else {
            $file = $this->upload_from_data( $request->get_body()$headers );
        }

        if ( is_wp_error( $file ) ) {
            return $file;
        }

        
Home | Imprint | This part of the site doesn't use cookies.