我试图使用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();
}
}
}发布于 2014-04-14 13:14:47
您必须正确地对SQL文件中的数据进行编码,就像在this对"How to insert BLOB and CLOB files in MySQL?"的答复中。
https://stackoverflow.com/questions/23060454
复制相似问题