Hi,
If you give me an answer and it works you wil get some NP$ and rep.
I made a script in a tutorial which is supposed to take the image, give it a url and that. I go to view the image,
and i get loads of rubbish. Here are my codes:
That was readdir.php which reads the directory for all the images.
view.php which shows the image:
Im not sure why it displays loads of symbols, maybe it goes wrong somewhere??
Thanks rep given.
If you give me an answer and it works you wil get some NP$ and rep.
I made a script in a tutorial which is supposed to take the image, give it a url and that. I go to view the image,
PHP:
?img=1
PHP:
<?
###############################
# DB CONNECTION
# CHANGE THESE VALUES
###############################
$dbcnx = mysql_connect("localhost", "root", "");
mysql_select_db("base64imgdb");
$path = "/toes";
$dir_handle = opendir($path) or die("Unable to open directory $path");
while ($file = readdir($dir_handle)) {
$filetyp = substr($file, -3);
if ($filetyp == 'gif' OR $filetyp == 'jpg') {
$handle = fopen($file,'r');
$file_content = fread($handle,filesize($file));
fclose($handle);
$encoded = chunk_split(base64_encode($file_content));
$sql = "INSERT INTO images SET sixfourdata='$encoded'";
mysql_query($sql);
}
}
closedir($dir_handle);
echo("complete");
mysql_close($dbcnx);
?>
PHP:
<?
$dbcnx = mysql_connect("localhost", "root", "");
mysql_select_db("base64imgdb");
$img = $_REQUEST["img"];
$result = mysql_query("SELECT * FROM images WHERE imgid=" . $img . "");
if (!$result) {
echo("<b>Error performing query: " . mysql_error() . "</b>");
exit();
}
while ($row = mysql_fetch_array($result) ) {
$imgid = $row["imgid"];
$encodeddata = $row["sixfourdata"];
}
mysql_close($dbcnx);
echo base64_decode($encodeddata);
?>[/img]
That was image.php which assigns the [php]?img=here
view.php which shows the image:
PHP:
<img src="http://localhost/Shop/pro/image.php?img=2">
Im not sure why it displays loads of symbols, maybe it goes wrong somewhere??
Thanks rep given.








