Image blob storing using python 2.7 and retrieving using php -


i doing work on project. want store image blob in mysql database using python , want retrieve using php.i working on raspberry pi.

here python code:

import mysqldb  import sys pil import image import base64 import cstringio import pil.image  db = mysqldb.connect(user='root', password='mungu',                           host='localhost',                           database='watchdogdb')  image = image.open('/var/www/html/abc.jpg') blob_value = open('/var/www/html/abc.jpg', 'rb').read() sql = 'insert img(images) values(%s)'     args = (blob_value, ) cursor=db.cursor() cursor.execute(sql,args)  db.commit() db.close() 

/// here php code :

$result = mysql_query("select id, image_time, ext,title {$table} order id desc limit 1"); if (mysql_num_rows($result) == 0) // table empty     echo '<ul><li>no images loaded</li>'; else {     echo '<ul>';      echo "<table border=1>";      while(list($id, $image_time,$ext,$title) = mysql_fetch_row($result))     {         // outputing list          echo "<td>";         echo "  <img height = 200 width='100' src='".$_server['php_self']."?show=$id'> ";         echo " <br> <a href='".$_server['php_self']."?show=$id'>{$title} </a> ";          echo " <br> <small>{$image_time}</small> ";         echo "</td>";     }    echo "</tabel>";     echo '</ul>'; } 

please guide me important or give solution fulfil requirements.

thanks in advance:)


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -