首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用php导入mysql blob数据

问使用php导入mysql blob数据
EN

Stack Overflow用户
提问于 2014-04-14 12:45:49
回答 1查看 237关注 0票数 0

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

代码语言:javascript
复制
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();
    }
}
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-04-14 13:14:47

您必须正确地对SQL文件中的数据进行编码,就像在this对"How to insert BLOB and CLOB files in MySQL?"的答复中。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23060454

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档