Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For a table like this:</p> <pre><code>CREATE TABLE binary_data ( id INT(4) NOT NULL AUTO_INCREMENT PRIMARY KEY, description CHAR(50), bin_data LONGBLOB, filename CHAR(50), filesize CHAR(50), filetype CHAR(50) ); </code></pre> <p>Here is a PHP example:</p> <pre><code>&lt;?php // store.php3 - by Florian Dittmer &lt;dittmer@gmx.net&gt; // Example php script to demonstrate the storing of binary files into // an sql database. More information can be found at http://www.phpbuilder.com/ ?&gt; &lt;html&gt; &lt;head&gt;&lt;title&gt;Store binary data into SQL Database&lt;/title&gt;&lt;/head&gt; &lt;body&gt; &lt;?php // Code that will be executed if the form has been submitted: if ($submit) { // Connect to the database (you may have to adjust // the hostname, username or password). mysql_connect("localhost", "root", "password"); mysql_select_db("binary_data"); $data = mysql_real_escape_string(fread(fopen($form_data, "r"), filesize($form_data))); $result = mysql_query("INSERT INTO binary_data (description, bin_data, filename, filesize, filetype) ". "VALUES ('$form_description', '$data', '$form_data_name', '$form_data_size', '$form_data_type')"); $id= mysql_insert_id(); print "&lt;p&gt;This file has the following Database ID: &lt;b&gt;$id&lt;/b&gt;"; mysql_close(); } else { // else show the form to submit new data: ?&gt; &lt;form method="post" action="&lt;?php echo $PHP_SELF; ?&gt;" enctype="multipart/form-data"&gt; File Description:&lt;br&gt; &lt;input type="text" name="form_description" size="40"&gt; &lt;input type="hidden" name="MAX_FILE_SIZE" value="1000000"&gt; &lt;br&gt;File to upload/store in database:&lt;br&gt; &lt;input type="file" name="form_data" size="40"&gt; &lt;p&gt;&lt;input type="submit" name="submit" value="submit"&gt; &lt;/form&gt; &lt;?php } ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload