how to upload image???
Posted: Thu May 13, 2004 1:29 am
for upload image, i hav create a readdir.php for insert and encode the files into image table.
readdir.php
readdir.php
Code: Select all
<?php
<?php
$dbcnx = @mysql_connect("localhost", "root", "");
if (!$dbcnx)
{
echo( "connection to database server failed!" );
exit();
}
if (! @mysql_select_db("mobile") )
{
echo( "Image Database Not Available!" );
exit();
}
$path = "./";
$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");
?>
?>