Forum Discussion
NathanHawe
5 years agoQrew Cadet
Fredrick, you can upload the base64 encoded file through the RESTful API. My PHP is rusty, but you'd do it similar to this:
------------------------------
Nathan Hawe
------------------------------
<?PHP
// This assumes that the field ID for the file attachment field is 6 and that
// $table_id, $host, and $user_token are defined earlier in the script.
$file = 'photo.png';
$encode_file = base64_encode(file_get_contents($file));
$request_body = json_encode(array(
"to" => $tableId,
"data" => array(
array(
"6" => array(
"value" => array(
"fileName" => $file,
"data" => $encode_file
)
)
)
)
));
$request = curl_init("https://api.quickbase.com/v1/records");
curl_setopt(
$request,
CURLOPT_HTTPHEADER,
array(
'QB-REALM-HOSTNAME: ' . $host,
'AUTHORIZATION: QB-USER-TOKEN ' . $user_token,
'Content-Type: application/json'
)
);
curl_setopt($request, CURLOPT_POSTFIELDS, $request_body);
?>​
------------------------------
Nathan Hawe
------------------------------
Related Content
- 2 months ago
- 6 months ago
- 6 months ago
- 6 months ago