gpt4 book ai didi

mysql - 使用php导入mysql blob数据

转载 作者:行者123 更新时间:2023-11-29 13:03:13 25 4
gpt4 key购买 nike

我正在尝试使用blob格式将图像数据保存在mysql中这些是使用 php 正确插入和检索的我有一个问题,我需要为某些数据创建一个单独的 sql 文件,其中包括 blob 数据,当我尝试导入 sql 文件时,它无法导入 blob 数据

include 'database.inc.php';
if (isset($_FILES['sqlfile']) && !empty($_FILES['sqlfile'])) {
$filename=$_FILES['sqlfile']['name'];
$tmp_filename=$_FILES['sqlfile']['tmp_name'];
move_uploaded_file($tmp_filename, $filename);
$file_content=file_get_contents($filename);
$commands = explode(';',trim($file_content));
foreach ($commands as $command) {
if(mysql_query($command)){
//header('Location: '.$_SERVER['HTTP_REFERER']);
} else {
//echo 'Failed to import with following command <br/>'.$command;
echo mysql_error();
}
}
}

最佳答案

您必须对 SQL 文件中的数据进行正确编码,如 this 中所示。回复"How to insert BLOB and CLOB files in MySQL?" .

关于mysql - 使用php导入mysql blob数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23060454/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com