相關(guān)關(guān)鍵詞
關(guān)于我們
最新文章
- PHP中opcode緩存簡(jiǎn)單用法分析
- thinkPHP控制器變量在模板中的顯示方法示例
- PHP move_uploaded_file() 函數(shù)(將上傳的文件移動(dòng)到新位置)
- dirname(__FILE__)的含義和應(yīng)用說(shuō)明
- thinkPHP5框架實(shí)現(xiàn)分頁(yè)查詢(xún)功能的方法示例
- PHP中單雙號(hào)與變量
- PHP獲得當(dāng)日零點(diǎn)時(shí)間戳的方法分析
- Laravel ORM對(duì)Model::find方法進(jìn)行緩存示例詳解
- PHP讀寫(xiě)文件高并發(fā)處理操作實(shí)例詳解
- 【CLI】利用Curl下載文件實(shí)時(shí)進(jìn)度條顯示的實(shí)現(xiàn)
PHP+Ajax無(wú)刷新帶進(jìn)度條圖片上傳示例

項(xiàng)目需求:1.PHP+Ajax無(wú)刷新帶進(jìn)度條圖片上傳,2.帶進(jìn)度條。所需插件:jquery.js,jquery.form.js。
最近在做一個(gè)手機(jī)web項(xiàng)目,需要用到Ajax上傳功圖片能,項(xiàng)目要求PHP無(wú)刷新上傳圖片,并且要帶進(jìn)度條,下面就來(lái)講一下我的實(shí)現(xiàn)方法,先看效果圖
本示例需要使用的是jquery.js,jquery.form.js,demo里面包含有,你可以在文章下方進(jìn)行下載。
第一步,建立前端頁(yè)面index.html
此段是前端展示內(nèi)容,這里需要說(shuō)明的是由于input:file標(biāo)簽顯示不太美觀(guān),所以我把它隱藏了。而使用一個(gè)a標(biāo)簽.uploadbtn來(lái)調(diào)用file標(biāo)簽的click事件,用來(lái)打開(kāi)并選擇文件。
注意:文件上傳時(shí)form的屬性enctype必須設(shè)置為:multipart/form-data
<!DOCTYPE HTML> <html> <head> <meta charset="UTF-8"> <title>php-ajax無(wú)刷新上傳(帶進(jìn)度條)demo</title> <meta name="description" content="" /> <meta name="viewport" content="width=device-width , initial-scale=1.0 , user-scalable=0 , minimum-scale=1.0 , maximum-scale=1.0" /> <script type='text/javascript' src='js/jquery-2.0.3.min.js'></script> <script type='text/javascript' src='js/jquery.form.js'></script> <link href="css/style.css" rel="external nofollow" type="text/css" rel="stylesheet"/> </head> <body> <div style="width:500px;margin:10px auto; border:solid 1px #ddd; overflow:hidden; "> <form id='myupload' action='upload.php' method='post' enctype='multipart/form-data'> <input type="file" id="uploadphoto" name="uploadfile" value="請(qǐng)點(diǎn)擊上傳圖片" style="display:none;" /> </form> <div class="imglist"> </div> <p class="res"></p> <div class="progress"> <div class="progress-bar progress-bar-striped"><span class="percent">50%</span></div> </div> <a href="javascript:void(0);" rel="external nofollow" onclick="uploadphoto.click()" class="uploadbtn">點(diǎn)擊上傳文件</a> </div> </body> </html>
相關(guān)文章
- smarty foreach函數(shù)
- Smarty中foreach的index、iteration,@count的使用
- 去掉織夢(mèng)建站或者仿站時(shí)首頁(yè)訪(fǎng)問(wèn)地址后的index.html
- MySQL修改編碼設(shè)置及亂碼問(wèn)題
- WampServer搭建PHP+Apache+MySQL環(huán)境
- 修改WAMP的www目錄的全過(guò)程
- 歸并排序:歸并操作的一種有效排序算法
- 如何編寫(xiě)PHP擴(kuò)展
- 如何克服php的register_global被關(guān)掉
- php正則表達(dá)式匹配img中任意屬性的方法