欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JQuery和PHP結(jié)合實(shí)現(xiàn)動(dòng)態(tài)進(jìn)度條上傳顯示

 更新時(shí)間:2016年11月23日 13:48:28   投稿:mrr  
本文給大家介紹JQuery和PHP結(jié)合實(shí)現(xiàn)動(dòng)態(tài)進(jìn)度條上傳顯示功能,本文分步驟給大家介紹的非常詳細(xì),感興趣的朋友一起看看吧

Windows 環(huán)境下的修改方法

第一步:修改在php5下POST文件大小的限制

1.編修php.ini

找到:max_execution_time = 30 ,這個(gè)是每個(gè)腳本運(yùn)行的最長(zhǎng)時(shí)間,單位秒,改為:max_execution_time = 150

找到:max_input_time = 60,這是每個(gè)腳本可以消耗的時(shí)間,單位也是秒,修改為:

max_input_time = 300

找到:memory_limit = 128M,這個(gè)是腳本運(yùn)行最大消耗的內(nèi)存,根據(jù)你的需求更改數(shù)值,這里修改為:memory_limit = 256M

找到:post_max_size = 8M,表單提交最大數(shù)據(jù)為 8M,此項(xiàng)不是限制上傳單個(gè)文件的大小,而是針對(duì)整個(gè)表單的提交數(shù)據(jù)進(jìn)行限制的。限制范圍包括表單提交的所有內(nèi)容.例如:發(fā)表貼子時(shí),貼子標(biāo)題,內(nèi)容,附件等…這里修改為:post_max_size = 20M

找到:upload_max_filesize = 2M ,上載文件的最大許可大小 ,修改為: upload_max_filesize = 10M (這里的大小根據(jù)需求來(lái)定)

第二步: Apache環(huán)境中的檔案上傳大小控制

修改位于Apahce目錄下的httpd.conf

添加下面內(nèi)容

LimitRequestBody 10485760

即10M=10*1024*1024,有的文章中提到應(yīng)改為 600000000

重新啟動(dòng)apache,就可以在設(shè)置里看到你要的大小

HTML部分

<form action="index/index/upload" method="POST" enctype="multipart/from-data" id="uploadform" onSubmit="return false">
<div class="inpuys">
<input type="file" name="file" id="uploadfile" value="選擇文件" class="cho">
<input type="submit" value="上傳" id="submit_btn" class="sub btn btn-info">
</div>
</form>

JS部分

<script type="text/javascript" src="{$Think.config.web_root}js/jquery.min.js"></script>
<script type="text/javascript" src="{$Think.config.web_root}js/jquery.form.js"></script>
<script src="http://cdn.bootcss.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var progressbox=$("#progressbox");
var progressbar=$("#progressbar");
var progress=$("#progress");
var completed="0%";
var options={
beforeSubmit:beforeSubmit,
uploadProgress:OnProgress,
success:afterSuccess,
resetForm:true
};
$("#uploadform").submit(function(){
$(this).ajaxSubmit(options);
return false;
});
function OnProgress(event,position,total,percentComplete ) {
progressbar.width(percentComplete + "%");
progress.html(percentComplete + "%");
}
function afterSuccess(){
$("#output").html("上傳完成!!");
}
function beforeSubmit(){
if (!$("#uploadfile").val()) {
$("#output").html("請(qǐng)選擇文件!!");
return false;
}
progressbar.width(completed);
progress.html(completed);
}
});
</script>

THINKPHP方法部分

public function upload(){
// 獲取表單上傳文件 例如上傳了001.jpg
$file = request()->file('file');
// 移動(dòng)到框架應(yīng)用根目錄/public/uploads/ 目錄下
$info = $file->move(ROOT_PATH . 'public' . DS . 'uploads');
if($info){
return "上傳成功";
}else{
// 上傳失敗獲取錯(cuò)誤信息
echo $file->getError();
}
}

以上所述是小編給大家介紹的JQuery和PHP結(jié)合實(shí)現(xiàn)動(dòng)態(tài)進(jìn)度條上傳顯示,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論