Search PHP Developer for Fileupload via Graphql API

hi @maximilian

Welcome to the community. About a year (or 2) ago I build this one in PHP. In my case the files itself are uploaded from my client device to my Wordpress server using WPForms file upload. On an event (button click) the function monday_upload_files is called. Not sure if this exactly meet your needs but maybe you can use it a a reference.

/************************************************************************************************************************************************************
* Name:			monday_upload_files 
* Arguments:	$board_id, $upload - board_id: DOCS board id where item needs to be created / $upload: array with file upload information
* Returns:		None
* Function:		Creates an item in the given board (first group) and attaches the file to the file column
*************************************************************************************************************************************************************/

function monday_upload_files( $board_id, $upload) {

	//Create a new item in the board
	$header = array(
		'User-Agent' => MONDAY_TEAM . ' GraphQL Client',
		'Authorization' => get_field('mondaykey', 'user_' . get_current_user_id()),
		'Content-Type' => 'multipart/form-data' 
	);

	//str_replace is used in an effort to get as close as possible to the original file name (sanitized by WPForms)
	$body = array(
		'query' => 'mutation {create_item (board_id: ' . $board_id . ', group_id: "topics", item_name: "' . str_replace("-"," ",pathinfo($upload['name'], PATHINFO_FILENAME)) . '") {id}}'
	);

	$response = wp_remote_post( MONDAY_URL, ['headers' => $header, 'body' => $body] );
	$arr1 = json_decode($response['body'], true);
	$item_id = $arr1['data']['create_item']['id'];	

	//Generate a boundary, needed for the Header (Content-Type) and the Body (to split in multiple parts)
	$boundary = wp_generate_password(24);
	$eol = "\r\n";

	$header = array(
		'User-Agent' => MONDAY_TEAM . ' GraphQL Client',
		'Authorization' => get_field('mondaykey', 'user_' . get_current_user_id()),
		'Content-Type' => 'multipart/form-data; boundary=' . $boundary
	);

	//We need to build the body from scratch because it is multipart with boundaries
	//Take care of the extra empty lines (twice $eol) before the actual query and file, otherwise an error 500 is returned

	$body = '--' . $boundary . $eol;
	$body .= 'Content-Disposition: form-data; name="query"' . $eol . $eol;
	$body .= 'mutation ($file: File!) {add_file_to_column (item_id: ' . $item_id . ', column_id: file, file: $file) {id}}' . $eol;
	$body .= '--' . $boundary . $eol;
	$body .= 'Content-Disposition: form-data; name="variables[file]"; filename="' . $upload['name'] . '"' . $eol;
	$body .= 'Content-Type: ' . $upload['type'] . $eol . $eol;
	$body .= file_get_contents($upload['value']);
	$body .= $eol . '--' . $boundary . '--';

	$response = wp_remote_post( MONDAY_URL . 'file/', ['headers' => $header, 'body' => $body] );

	unlink(ABSPATH . substr($upload['value'], 25));
}