I would like to upload the file contents using DB_CONTENT directly into my SQL Server database.
However I am confused about the datatype required by that field, is it binary (varbinary) or string (nvarchar)?
The documentation on doing this is a little sparse in my opinion.
Regardless of if I use varbinary or nvarchar, if I upload any file, the server returns an error but without any description as if it just aborts. No errors in the console or PHP logs, nothing.
I have traced the point of the abort to line 687 in Upload.php; $res = $q->exec();
.
If i var_dump a variable before and after this call it only shows the former but not the latter.
My guess is it has to do with line 627; $q->set($column, file_get_contents($upload['tmp_name']));
This reads the file contents into a string but it doesn't play well with uploading to the database maybe because it contains some bad characters.
If I use datatype nvarchar(max) for the field, and change line 627 to:
$q->set( $column, base64_encode(file_get_contents($upload['tmp_name'])) );
it uploads correctly.
If I do this with datatype varbinary, the insert fails (but atleast with an error message) because cannot implicitely convert varchar to varbinary without a CONVERT statement.
so the question is, what is the correct method to use DB_CONTENT?