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();
    }
}
}

1 Answer 1

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?".

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.