上一篇:PHP脚本与数据库功能详解(上)
利用PHP将文件保存到数据库
数据库是数据组织、存储的中心。将要处理的也可能是各种数据,包括程序、文件、报表,甚至音频、视频数据。由于通过浏览器,个人用户只能填写少部分的个人简历。因此,我们这里示范用户个人简历上载的功能。其他类型的数据可以模仿此例进行操作。
首先是信息收集页面。让用户选择要上载的文件。此页面的html代码如下:
〈!– begin of post.htm–〉
〈p〉 〈/p〉
〈form method="POST" action="insert.php" ENCTYPE="multipart/form-data"〉
〈p〉〈b〉个人简历提交〈/b〉〈/p〉
〈p〉姓名:〈br〉
〈input type="text" name="Name" size="20"〉〈/p〉
〈p〉个人简介:〈br〉
〈textarea rows="2" name="Intro" cols="20"〉〈/textarea〉〈/p〉
〈p〉简历文件:〈br〉
〈input type="file" name="ResuFile"〉〈/p〉
〈p〉〈input type="submit" value="提交" name="B1"〉〈/p〉
〈/form〉
〈!-End of post.htm–〉
注意,ENCTYPE关键字一定不能省,否则文件无法正确上载。
这里,我们再把向数据库插入记录的代码重新设计:
〈?
//begin of file insert.php
if($ResuFile != "none")
//确定用户选择了文件
{
$Size = filesize($ResuFile);
//确定文件大小
$mFileData = addslashes(fread(fopen($ResuFile, "r"), $Size));
//读取文件,对内容进行处理
unlink($ResuFile);
//删除上载临时文件
}
$LinkID=@mysql_connect("localhost", "root" , "") or die("不能连接到数据库服务器!可能是数据库服务器没有启动,或者用户名密码有误!");
$DBID = @mysql_select_db("ResumeDB",$LinkID) or die("选择数据库出错,可能是您指定的数据库不存在!");
$query = "insert into Resume(Name,Intro,ResuFile) values(‘$Name’, ‘$Intro’, ‘$mFileData’)";
$result = @mysql_query("$query",$LinkID); //执行查询,插入文件到数据库
if(! $result)
echo "数据插入失败!";
else
echo "文件上载成功!";
@mysql_close($LinkID);
//end of file insert.php
?〉
有了上面的基础,写出从数据库读数据的程序应该很简单了。需要注意的是文件向客户发送的方法。服务器必须向浏览器发送头信息,说明将要发送的数据为word文档。如果用户计算机装有MSWord,浏览器将自动调用word进行文档显示。
我们可以设置一个超级链接,来下载这个Word文件:
〈?
//begin of file show.php
$LinkID=@mysql_connect("localhost", "root" , "") or die("不能连接到数据库服务器!可能是数据库服务器没有启动,或者用户名密码有误!");
波比源码 » PHP脚本与数据库功能详解(中)
generic levofloxacin buy levofloxacin sale
spironolactone tablet finasteride pill diflucan 200mg sale
order generic fildena 100mg order generic fildena 50mg buy robaxin without prescription
buy cialis 40mg online cheap buy cheap cialis viagra sildenafil 25mg
buy anastrozole 1mg online order anastrozole 1 mg sale female viagra cvs
order prograf 5mg prograf uk buy ursodiol 300mg pill
order accutane 20mg online cheap order prednisone 10mg for sale prednisone 5mg drug
order piracetam 800 mg sale nootropil 800 mg over the counter cheap viagra without prescription
order cialis 20mg pills buy clomipramine 25mg generic anafranil generic
itraconazole pills prometrium online buy generic tinidazole
buy glycomet 1000mg without prescription cheap cialis 40mg order cialis 5mg without prescription
buy omeprazole 20mg online cheap play money poker online real casino online
xenical 120mg pill cheap zovirax 800mg buy acyclovir for sale
tadalafil 20mg without prescription cialis 10mg ca clopidogrel 75mg brand
purchase lioresal sale order toradol 10mg online cheap purchase toradol sale
buy gloperba pills colchicine pills blackjack online game
tadalafil pill buy cipro 1000mg online cheap cipro 1000mg price
buy generic cephalexin 500mg buy keflex 250mg generic buy erythromycin
golden nugget online casino slots games order tadalafil 5mg sale
cost of viagra 100mg viagra next day cialis 10mg for sale
slot game no deposit bonus codes cialis 10mg drug
buy zithromax sale order zithromax 250mg pills gabapentin oral
casino bonus buy stromectol for humans modafinil price
sildenafil online buy budesonide without prescription purchase budesonide for sale
buy tadacip 20mg sale buy diclofenac without prescription indocin for sale
clarithromycin 500mg us buy biaxin 250mg generic order antivert 25mg online
naproxen 500mg drug naproxen order online buy prevacid generic
purchase actos for sale sildenafil sale oral viagra 100mg
montelukast 5mg price buy sildenafil 50mg sale order viagra 50mg online
planning poker online play poker online play for real online casino games
buy adalat 10mg order aceon 8mg generic fexofenadine 120mg ca
free slot buy custom research papers write essay service
write essays for money buy sulfasalazine 500 mg online cheap generic azulfidine
buy mesalamine 800mg pills buy asacol 800mg online avapro online buy
diamox uk isosorbide 40mg pill buy imuran for sale
order digoxin 250mg pill order lanoxin generic buy molnunat online
purchase carvedilol pill carvedilol 25mg drug elavil us
dapoxetine 60mg sale buy priligy 30mg generic cheap motilium 10mg
Thank you for content. Area rugs and online home decor store. Hello Administ . Metropol Halı Karaca Halı Öztekin ve Selçuklu Halı Cami Halısı ve Cami Halıları Türkiye’nin En Büyük Cami Halısı Fabrikasıyız…
buy generic indomethacin brand flomax 0.4mg cenforce price
cost tadalafil 10mg buy tadalafil 10mg pills amoxicillin order
tricor 160mg oral viagra us buy viagra 50mg for sale
esomeprazole 20mg pill buy generic biaxin 250mg order furosemide 100mg generic
generic minocin 100mg order neurontin 600mg for sale hytrin 5mg canada
cost accutane buy deltasone generic order ampicillin pills
purchase fildena pills finasteride pills order propecia without prescription
is ivermectin a prescription drug erectile dysfunction medicines buy prednisone 20mg online cheap
order accutane generic buy absorica pill buy zithromax online
allergy drugs list cost synthroid cheap augmentin
order prednisolone 10mg pill buy generic prednisolone 20mg lasix over the counter
order vibra-tabs without prescription buy vardenafil generic acyclovir 400mg usa
order azathioprine 25mg online order azathioprine 25mg pills naproxen 250mg pill
order oxybutynin generic order prograf pill trileptal 600mg sale
cefdinir 300 mg sale order protonix 20mg generic brand protonix 40mg
purchase dapsone generic order mesalamine 400mg generic tenormin for sale online
order alfuzosin 10mg online cheap trazodone order online order diltiazem 180mg online
buy viagra 50mg without prescription sildenafil for men over 50 buy cialis 10mg for sale
buy ezetimibe pill order tetracycline online cheap buy generic methotrexate 2.5mg
order levaquin without prescription buy levaquin pills purchase bupropion online cheap
order warfarin 5mg generic zyloprim ca buy zyloprim 100mg for sale
zyrtec ca brand zoloft 50mg order zoloft 100mg pill
generic cenforce 100mg order cenforce glucophage 1000mg usa
lexapro buy online buy fluoxetine 20mg pill revia 50 mg tablet
atorvastatin tablet buy viagra online cheap sildenafil overnight
letrozole pills order viagra 100mg pills viagra usa
cialis 20mg us cialis buy overnight new ed pills
stromectol ivermectin buy stromectol pills buy isotretinoin no prescription
order provigil order promethazine for sale deltasone us
generic amoxil 1000mg buy amoxicillin tablets purchase prednisolone
buy prednisolone tablets furosemide 100mg us buy furosemide 100mg online cheap
monodox usa buy augmentin 625mg for sale order augmentin sale
buy tenormin pills for sale order femara 2.5mg online cheap femara 2.5mg ca
order levoxyl generic levitra pills vardenafil 20mg brand
buy metformin 1000mg sale buy generic atorvastatin norvasc 5mg tablet
how to buy biltricide hydrochlorothiazide 25 mg sale cyproheptadine 4mg us
lisinopril 5mg generic cost omeprazole 10mg metoprolol price
order orlistat generic buy xenical online cheap buy allopurinol online cheap
hyzaar canada purchase topiramate for sale topiramate 100mg usa
rosuvastatin order buy domperidone without a prescription buy motilium 10mg without prescription
brand sumatriptan order imitrex 50mg online cheap buy dutasteride cheap
buy tetracycline 250mg without prescription lioresal pills baclofen 25mg usa
duloxetine 20mg us buy duloxetine online cheap piracetam 800mg without prescription
betnovate where to buy order sporanox 100 mg pill buy cheap generic sporanox
combivent generic order generic combivent 100mcg order generic zyvox 600 mg
starlix 120 mg without prescription atacand drug where to buy candesartan without a prescription
oral nebivolol bystolic 5mg for sale buy clozaril generic
simvastatin uk purchase valacyclovir pills viagra tablets
order estrace generic order estradiol generic buy prazosin 1mg generic
vermox online mebendazole ca tadalis pills
avanafil 100mg canada diclofenac online order buy cambia cheap
indocin 75mg cost indomethacin 50mg generic buy generic cefixime 200mg
trimox 250mg tablet amoxicillin online order biaxin over the counter
clonidine 0.1 mg cost spiriva 9mcg cheap buy generic tiotropium bromide 9mcg
purchase sildenafil pill sildenafil medication sildalis price
buy naproxen for sale lansoprazole 15mg canada lansoprazole 30mg tablet
adalat 10mg tablet buy aceon without a prescription order fexofenadine 120mg pill
brand metoprolol 50mg tenormin 50mg drug medrol 4mg online
buy crestor 20mg without prescription crestor 10mg for sale buy generic motilium
cost toradol 10mg toradol 10mg price inderal 10mg brand
bactrim online buy order bactrim 480mg generic buy generic cleocin
how to get clopidogrel without a prescription plavix 75mg sale warfarin 2mg canada
purchase erythromycin for sale nolvadex 20mg ca order tamoxifen 20mg pills
avodart 0.5mg pills order mobic 7.5mg sale buy meloxicam 15mg without prescription
purchase aurogra pills buy sildalis without a prescription estradiol 1mg canada
celebrex usa purchase flomax sale ondansetron 4mg for sale
buy lamictal pills for sale order vermox 100mg pills where to buy minipress without a prescription
buy spironolactone generic buy generic spironolactone 25mg valtrex pills
finasteride where to buy buy propecia 5mg generic buy viagra without prescription
order tretinoin gel sale order tadalafil 10mg without prescription purchase avana online
cheap tadalafil order tadacip buy indocin 75mg
movfor tablet buy cefdinir 300mg without prescription buy omnicef 300mg online cheap
purchase lansoprazole sale pantoprazole 40mg tablet protonix cost
cheap pyridium 200 mg buy singulair cheap cost amantadine 100 mg
order dapsone generic purchase adalat without prescription order perindopril 4mg generic
buy arcoxia 60mg for sale order asacol 400mg for sale astelin 10ml sprayer
avapro 150mg without prescription buy avapro no prescription buspirone 10mg ca
cordarone for sale online carvedilol sale dilantin online buy
aviator oyunu hilesi apk
aviator taktikleri
oxytrol without prescription buy fosamax pill buy generic alendronate online
nitrofurantoin order nortriptyline 25 mg for sale pamelor tablet
glucotrol over the counter cost glipizide buy betnovate 20gm generic
buy tindamax pill tindamax drug cost nebivolol 5mg
captopril tablet buy atacand cheap order carbamazepine pill
buy frumil pills for sale frumil 5 mg over the counter purchase acivir cream