I am trying to pull a picture from my server (which has pictures stored in a mysql db). I am not getting a picture back correctly when I attempt to get to call it however? Here is how I attempt to set up the php server response...
if(mysql_query("insert into Personal_Photos (Email, Pics) values('$email', '$data')"))
{
$query="select Pics, MAX(ID) from Personal_Photos where Email='$email'";
$result=mysql_query($query) or die("Error: ".mysql_error());
$row=mysql_fetch_array($result);
//$mime = 'image/yourtype';
//$base64 = base64_encode($contents);
//$uri = "data:$mime;base64,$base64";
header("Content-type: image/jpg");
print($row['Pics']);
}
Here is the jquery Form call that attempts to get this picture...
$('#profilepicbutton').live('change', function(){
$("#preview").html('');
$("#preview").html('<img src="loader.gif" alt="Uploading...."/>');
$("#registerpt3").ajaxForm({
target: '#preview',
success: function(data)
{
$("#preview").html('');
$("#preview").append("<img src="+data+"></img>");
}
}).submit();
});
UPDATE: GETTING WEIRD RESULT Getting a weird result when I change my php code to this
if(mysql_query("insert into Personal_Photos (Email, Pics) values('$email', '$data')"))
{
$query="select Pics, MAX(ID) from Personal_Photos where Email='$email'";
$result=mysql_query($query) or die("Error: ".mysql_error());
$row=mysql_fetch_array($result);
//$mime = 'image/yourtype';
//$base64 = base64_encode($contents);
//$uri = "data:$mime;base64,$base64";
//header("Content-type: image/jpg");
echo '<img src="data:image/jpeg;base64'.base64_encode($row['Pics']).'"/>';
}