Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre class="lang-sql prettyprint-override"><code>CREATE TABLE `pix` ( `pic_id` INT(11) NOT NULL auto_increment, `pic_name` VARCHAR(100) NOT NULL, `pic_data` LONGBLOB NOT NULL, PRIMARY KEY (`pic_id`) ) engine=innodb DEFAULT charset=latin1; </code></pre> <p>Get 2 php files:- Image.php, showImage.php.</p> <p>Set Connection parameters accordingly.</p> <pre class="lang-php prettyprint-override"><code>/* Image.php*/ &lt;?php $con = mysql_connect("127.0.0.1:3306", "root", ""); if (!$con) { die("Could not connect: " . mysql_error()); } $DB = mysql_select_db("test", $con); move_uploaded_file($_FILES["uploadedfile"]["tmp_name"], "latest.img"); $instr = fopen("latest.img","rb"); $image = addslashes(fread(fopen("latest.img","r"),filesize("latest.img"))); mysql_query ("insert into pix (pic_name, pic_data) values ("myImage", "'.$image.'");"); ?&gt; &lt;html&gt; &lt;form enctype="multipart/form-data" method="POST"&gt; &lt;img src=showImage.php?gim=1 width=500 height=150 alt="hell"&gt; &lt;br&gt; &lt;hr&gt; &lt;input type="hidden" name="MAX_FILE_SIZE" value="100000" /&gt; Choose a file to upload( &lt;100 KB): &lt;input name="uploadedfile" type="file" /&gt; &lt;br/&gt; &lt;input type="submit" value="submit" name="submit" /&gt; &lt;/form&gt; &lt;html&gt; /*showImage.php*/ &lt;?php $con = mysql_connect("127.0.0.1:3306", "root", ""); if (!$con) { die(“Could not connect: ” . mysql_error()); } $DB = mysql_select_db("test", $con); $res = @mysql_query("select * from pix order by pic_id desc limit 1"); if ($row = @mysql_fetch_assoc($res)) { $title = htmlspecialchars($row[pic_name]); $bytes = $row[pic_data]; } header("Content-type: image/jpg"); print $bytes; mysql_close(); ?&gt; </code></pre>
    singulars
    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. This table or related slice is empty.
    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