字體:小 中 大 | |
|
|
2019/09/17 15:08:54瀏覽51|回應0|推薦0 | |
CREATE TABLE t_image (f_id int NOT NULL AUTO_INCREMENT PRIMARY KEY, f_image BLOB ); //put image to mysql <?php include("../catlib.php"); ?> <?PHP //http://192.168.0.10/picphp/1.php?pic=4.jpeg $user1=bunny; $password1=12341234; $database1=d_vegetable; //$Picture="1.jpeg"; $Picture=$_GET[pic]; if($Picture == ""){ die("no _GET pic"); } html_head(); header1(); no_cache(); head_body(); If($Picture != "none") { $PSize = filesize($Picture); echo "size $PSize";br(); $file_content=base64_encode(fread(fopen($Picture, "rb"), $PSize)); $conn=mysqli_connect(localhost,$user1,$password1,$database1); if ($conn) { echo"ok1";br(); $st1="INSERT INTO t_image VALUES(NULL,$file_content)"; if (mysqli_query($conn,$st1)){ echo"ok2";br(); } else { die("Cant Perform Query"); } } else { echo "-1"; } } else { echo"You did not upload any picture"; } body_html_s(); ?> //get image form mysql <?php include("../catlib.php"); ?> <?PHP //http://192.168.0.10/picphp/2.php?pic_id=4 $user1=bunny; $password1=12341234; $database1=d_vegetable; $pic_id=$_GET[pic_id]; if($pic_id == ""){ die("no _GET pic_id"); } $conn=mysqli_connect(localhost,$user1,$password1,$database1); if ($conn) { $st1="select f_image from t_image where f_id=$pic_id"; if ($picdata=mysqli_query($conn,$st1)){ header("Content-Type:image/jpeg"); echo base64_decode(mysqli_fetch_row($picdata)[0]); } else { die("Cant Perform Query"); } } else { echo "-1"; } ?> |
|
( 心情隨筆|心情日記 ) |