hai, guys how to open a image directory in server and upload picture from server to database

I'm no expert here but I've read loads on whether it is better to store the image in the file system or in the database, opinion seems to be divided and you could spend a lifetime reading through all documents trying to make an opinion for yourself.

For my solutions I store the image in the file system and a url to the image in the database.

I have a simple table with 3 columns
1 id INT
2 url VARCHAR
3 desc VARCHAR

then from a form with 3 fields I upload images to the file system and add the path and description to the database.

1 input=file name=pic
2 input=text name=desc

once the image has been chosen (from local, server or remote) and a name added I post to a php script

the php constructs the image path and moves the image to the file system (local, server or remote)

something like

$target_path = "foldername/";
$path_builder1="<img src=";
$path_builder2=">";
$pic= $_FILES['pic']['name'];
$desc=$_POST['desc'];
$url=$path_builder1.$targetpath.$image_name.$path_builder2;

$target_path = $target_path. basename( $_FILES['pic']['name']); 

if(move_uploaded_file($_FILES['pic']['tmp_name'], $target_path)) {

the last step is to add the image description and path to the database

$sqla="INSERT INTO table (desc, url) VALUES ('$desc','$url')";

If you want to use the image across severl domains it is better to store in a database via binary, but you will need to check with your hosting provider if its ok.
also it helps to put a size limit on the upload. say 100kB which allows for a medium good quality image about 600px wide after compression
I will post a tutorial on mysql image processing when I have time

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.