mysql - PHP : Getting link to image uploaded to directory -


i adding posts in database , against each post there image. example there product table , against each product i've id, quanitity , price.

now store image in

if ( isset($_post["uploadimg"]) ) {     $file_name =$_files["image"]["name"];     $file_type=$_files["image"]["type"];     $file_size=$_files["image"]["size"];     $tmp_name=$_files["image"]["tmp_name"];      if ( $file_name ) {         if ( move_uploaded_file($tmp_name,"images/$file_name") ) {             // here         }     } } 

fetch

$folder = "images"; if ( is_dir($folder) ) {     if ( $handle= opendir($folder) ) {         while (($file=  readdir($handle))!=false) {             if($file==='.' || $file==='..')  continue;             echo '<img src="images/'.$file.'" width="100" height="100" >';         }         closedir($handle);      } } 

now product image goes folder , details product go db, using insert query.

my question how relate image product details while fetching products?

i mean how store reference image may know image product details.

you can store path or image name in database.

you must have new column in product table imgpath or this.

i'm not sure if answers question hope you.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

React Native allow user to reorder elements in a scrollview list -

multithreading - Exception in Application constructor -