怎么在mysql傳圖片 mysql上傳圖片

怎么上傳圖片并插入MYSQL

看你的表,圖片不是保存在mysql數(shù)據(jù)庫(kù)中,數(shù)據(jù)庫(kù)中只是保存了圖片的路徑。想保存的數(shù)據(jù)庫(kù)中必須定義字段為longblob類型如:`image` longblob ,然后

讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來(lái)自于我們對(duì)這個(gè)行業(yè)的熱愛(ài)。我們立志把好的技術(shù)通過(guò)有效、簡(jiǎn)單的方式提供給客戶,將通過(guò)不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長(zhǎng)期合作伙伴,公司提供的服務(wù)項(xiàng)目有:域名注冊(cè)、網(wǎng)頁(yè)空間、營(yíng)銷軟件、網(wǎng)站建設(shè)、西塞山網(wǎng)站維護(hù)、網(wǎng)站推廣。

?

$connect?=?MYSQL_CONNECT(?"localhost",?"root",?"admin")?or?die("Unable?to?connect?to?MySQL?server");?

mysql_select_db("blogsystem")?or?die("Unable?to?select?database");?

$data?=?addslashes(fread(fopen($form_data,?"r"),?filesize($form_data)));?

$result=MYSQL_QUERY(?"INSERT?INTO?ccs_image?(description,bin_data,filename,filesize,filetype)?VALUES?('$form_description','$data','$form_data_name','$form_data_size','$form_data_type')");???

$id=?mysql_insert_id();??

print?"pThis?file?has?the?following?Database?ID:?a?href='get_data.php?id=$id'b$id/b/a";?

MYSQL_CLOSE();?

?

怎么把圖片上傳到MYSQL中?

//自己寫(xiě)限制

div class="daohang"

div class="daohang_title"添加大三平面作品/div

li class="ti"

div class="bd"a href="../main_pingmian_1" target="mainFrame"大三作品/a/div

div class="bd"a href="../main_pingmian_2" target="mainFrame"大二作品/a/div

div class="bd"a href="../main_pingmian_3" target="mainFrame"大一作品/a/div

/li

/divdiv class="daohang"

form nname="form1" method="post" action="pm_cheak.php" onSubmit="return jiancha()" enctype="multipart/form-data" //注意 enctype="multipart/form-data一定要有

div class="daohang_title"請(qǐng)認(rèn)真填寫(xiě)平面作品的資料/div div class="he"

li class="he_1"創(chuàng)作人/li

li class="he_2"input name="pm_zuozhe" type="text" id="pm_zuozhe" value="" size="8" maxlength="4" //li

/div

div class="he"

li class="he_1"span class="lanmu_title"作品說(shuō)明/span/li

li class="he_2"input name="pm_text" type="text" id="pm_text" value="" size="30" maxlength="30" / 最多可以輸入15個(gè)漢字或30個(gè)字母!/li

/div

div class="he"

li class="he_1"連接地址/li

li class="he_2"input name="pm_href" type="text" id="pm_href" value="" size="30" maxlength="30" /

如:;/li

/div

div class="he"

li class="he_1"作品圖片/li

li class="he_2"

label

input type="file" name="pm_images" style="width:220; border:1 solid #6899B7; font-size:9pt; size="14" /label 允許上傳文件類型為:jpg|jpeg|png|pjpeg|gif|bmp

/li

/div

div class="he"

li class="he_1"/li

li class="he_2"

label

input type="submit" name="upload" value="提交" /

/label

label

input type="reset" name="button2" id="button2" value="重置"

/label

input name="date" type="hidden" id="date" value=""

/li

/div

/form/div 程序部分pm_cheak.php: ?

include ("../../../../conn.php");

if ($_POST['upload'] == '提交') { $pm_zuozhe = $_POST[pm_zuozhe];

$pm_text = $_POST[pm_text];

$pm_href = $_POST[pm_href];//一一對(duì)應(yīng) $pm_date = date("Y-m-d"); $link=date("YmjHis"); //獲取當(dāng)前時(shí)間

//為表單中提交的數(shù)據(jù)重新命名,以當(dāng)前時(shí)間和隨機(jī)數(shù)作為名稱,其中使用$_FILES獲取表單中真實(shí)的名稱,使用strstr函數(shù)獲取文件的后綴

$path=$link.mt_rand(1000,9999).strstr($_FILES["pm_images"]["name"],".");

$address="../../../../images/pm_btn/".$path; //定義文件上傳的路徑

move_uploaded_file($_FILES["pm_images"]["tmp_name"],$address); //將文件上傳到指定的文件中

$pm_images="images/pm_btn/".$path; //獲取上傳文件在服務(wù)器中的存儲(chǔ)路徑

//將表單中提交的數(shù)據(jù)存儲(chǔ)到數(shù)據(jù)庫(kù)中 $sql = mysql_query("insert into pm(pm_zuozhe,pm_text,pm_href,pm_images,pm_date)values('$pm_zuozhe','$pm_text','$pm_href','$pm_images','$pm_date')");//執(zhí)行插入語(yǔ)句

mysql_close($conn);//關(guān)閉連接

}

echo ("scriptalert('大三平面作品添加成功');window.location.href='add_pm_zuopin.php';/script");

?

meta http-equiv="Content-Type" content="text/html; charset=GBK" / //注意編碼格式

mysql數(shù)據(jù)庫(kù)怎么導(dǎo)入圖片,我是想用php+mysql做一個(gè)項(xiàng)目的

一般情況是將圖片地址寫(xiě)入數(shù)據(jù)庫(kù),將圖片文件上傳到FTP中,如果要將圖片寫(xiě)入mysql,你可以先將圖片轉(zhuǎn)成base64后再寫(xiě)入mysql,其實(shí)真沒(méi)這個(gè)必要!

網(wǎng)站名稱:怎么在mysql傳圖片 mysql上傳圖片
分享地址:http://www.muchs.cn/article36/dohscsg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營(yíng)銷推廣、網(wǎng)站導(dǎo)航、響應(yīng)式網(wǎng)站、網(wǎng)站排名、商城網(wǎng)站、品牌網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都做網(wǎng)站