當前位置:首頁 » 文件管理 » php上傳圖片資料庫

php上傳圖片資料庫

發布時間: 2025-03-20 20:43:34

Ⅰ 新手請教多個圖片上傳,怎麼寫入資料庫(php)

原理都一樣,循環接參,你列印一下它的參數就夠就明白了,存儲資料庫,可以將圖片路徑之間用|或者逗號,或者json 系列化來存儲:

<?php
print_r($_FILES);//你可以列印一下它,看看它的結構
if(!empty($_FILES)){
foreach($_FILES['file']['name']as$k=>$v){
//$_FILES["file"]都變成$_FILES["file"][$k]操作進行操作吧
if($_FILES['file'][$k]['error']==0){
$filetype=array("jpg","JPG");
$arr=explode(".",$_FILES["file"][$k]["name"]);
...//同樣的代碼
}
}
}
?>
<formname=""action=""method="post"enctype="multipart/form-data">
<inputtype="file"name="file[]"/><br/>
<inputtype="file"name="file[]"/><br/>
<inputtype="file"name="file[]"/><br/>
<inputtype="file"name="file[]"/><br/>
<inputtype="file"name="file[]"/><br/>
<inputtype="file"name="file[]"/><br/>

<inputtype="submit"name="a"value="提交"/>
</form>

Ⅱ php圖片以二進制的方式存儲在資料庫的問題

mysql自己有select語句,用這個來操作
比如說你每個圖片主碼設一個auto_increasment的id(自動以1,2,3這樣排序下去的方式存圖片),然後比如說一共有50張圖片,依次讀出for(i=0,i<50,i++){select
圖片
from
資料庫
where(圖片id=
i);}就這樣可以依次根據圖片的id讀下去。

Ⅲ PHP+MySql要如何做才能上傳圖片後在資料庫中顯示圖片路徑,要能用的!

在上傳代碼中首先獲取上傳文件圖片的文件名$filename,然後insert的時候將獲取的文件名insert到adminphoto中
mysql_query("insert into admindata (adminphoto) values ('images/".$filename."')")

顯示的時候
<img src="<?=$AdminPhoto?>">" width="111" height="144">
$AdminPhoto為查詢到你資料庫的圖片路徑
$AdminPhoto替換成$rs->AdminPhoto

熱點內容
python解壓gz 發布:2025-07-07 22:03:19 瀏覽:619
安卓俄羅斯方塊源碼 發布:2025-07-07 21:56:11 瀏覽:474
安卓手機之王是哪個手機 發布:2025-07-07 21:44:30 瀏覽:613
安卓照片存儲位置 發布:2025-07-07 21:31:58 瀏覽:964
kingcmsphp 發布:2025-07-07 21:31:49 瀏覽:393
微信的鎖屏密碼是什麼 發布:2025-07-07 21:28:52 瀏覽:757
樹莓派自帶ftp開啟 發布:2025-07-07 21:11:41 瀏覽:51
智慧樹用腳本會怎麼樣 發布:2025-07-07 21:05:48 瀏覽:516
隨機啟動腳本 發布:2025-07-05 16:10:30 瀏覽:536
微博資料庫設計 發布:2025-07-05 15:30:55 瀏覽:32