0

i am trying to save image data in mysql using blob format these are inserted and retrieved correctly using php i have a problem , i need to create a separate sql file for certain data which includes blob data when i try to import the sql file it is not able to import the blob data

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();
    }
}
}
1234567
  • 2,226
  • 4
  • 24
  • 69

1 Answers1

1

You'll have to properly encode the data in the SQL file, like in this answer to "How to insert BLOB and CLOB files in MySQL?".

Community
  • 1
  • 1
JimmyB
  • 12,101
  • 2
  • 28
  • 44