hisham
IS-IT--Management
- Nov 6, 2000
- 194
I use the following code to store image in a database:
-------------------------------------
<?php
if (!$_POST['uploaded']){
?>
<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post"
ENCTYPE="multipart/form-data">
Upload:<br><br>
<input type="file" name="image"><br><br>
<input type="hidden" name="uploaded" value="1">
<input type="submit" value="Upload">
</form>
<?
}else{
$ip=$REMOTE_ADDR;
if (!empty($image)){
copy($image, "../temporary/".$ip."");
$filename1 = "../temporary/".$REMOTE_ADDR;
$fp1 = fopen($filename1, "r");
$contents1 = fread($fp1, filesize($filename1));
fclose($fp1);
$encoded = chunk_split(base64_encode($contents1));
mysql_query("INSERT INTO images (img,data)"."VALUES ('NULL', '$encoded')");
unlink($filename1);
}
}
?>
----------------------------------------------------
and work fine. i want to run this code to store all images in my folder "images" in the database without using the uploading process. any help?
thanks in advance.
-------------------------------------
<?php
if (!$_POST['uploaded']){
?>
<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post"
ENCTYPE="multipart/form-data">
Upload:<br><br>
<input type="file" name="image"><br><br>
<input type="hidden" name="uploaded" value="1">
<input type="submit" value="Upload">
</form>
<?
}else{
$ip=$REMOTE_ADDR;
if (!empty($image)){
copy($image, "../temporary/".$ip."");
$filename1 = "../temporary/".$REMOTE_ADDR;
$fp1 = fopen($filename1, "r");
$contents1 = fread($fp1, filesize($filename1));
fclose($fp1);
$encoded = chunk_split(base64_encode($contents1));
mysql_query("INSERT INTO images (img,data)"."VALUES ('NULL', '$encoded')");
unlink($filename1);
}
}
?>
----------------------------------------------------
and work fine. i want to run this code to store all images in my folder "images" in the database without using the uploading process. any help?
thanks in advance.