Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Upload Images from folder to Mysql Database with PHP

Status
Not open for further replies.

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.
 
please refer t the php file functions. it has a whole range of functions to do just that...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top