Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 以varbinary格式插入PDF文件内容(最大值)_Php_Sql_Sql Server - Fatal编程技术网

Php 以varbinary格式插入PDF文件内容(最大值)

Php 以varbinary格式插入PDF文件内容(最大值),php,sql,sql-server,Php,Sql,Sql Server,我把文件贴在表格上 之后,我将内容存储在$content中 $extract = fopen($tmp_name, 'r'); $content = fread($extract, $size); $content = addslashes($content); fclose($extract); 现在我想知道如何使用varbinary(MAX)类型在我的SQL字段中存储$content 这样做是行不通的 $docsql = "I

我把文件贴在表格上

之后,我将内容存储在$content中

    $extract = fopen($tmp_name, 'r');
    $content = fread($extract, $size);
    $content = addslashes($content);
    fclose($extract);
现在我想知道如何使用varbinary(MAX)类型在我的SQL字段中存储$content

这样做是行不通的

                $docsql = "INSERT INTO DOKUMENT (
                        Typ,
                        Dateiname,
                        Dokument,
                        JournalID 
                    ) VALUES (
                        2,
                        :Dateiname,
                        :Dokument,
                        :JournalID
                    )";

                $d = $db->prepare($docsql);
                $d->bindParam(':Dateiname', $filename);
                $d->bindParam(':Dokument', $content);
                $d->bindParam(':JournalID', $journalID);
                $de = $d->execute();

错误是,它不是此字段的正确格式,有什么想法吗?

假设您使用的是PDO,这可能会有所帮助:。但这不是最好的办法。在数据库中存储文件不是最佳做法。如果可以,请存储文件的路径,而不是二进制数据。SQL Server不是文档存储。我知道,但我需要将其存储到我的数据库中,因为我打开了存储在此选项卡a REP系统中的此“文件”。。。所以我需要像我说的那样做,谁在抛出错误?php、Web服务器还是sql?请共享实际的错误消息。