當前位置:首頁 » 網頁前端 » web上傳文件進度條
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

web上傳文件進度條

發布時間: 2022-09-28 01:12:27

⑴ c#,winform webservice傳輸量大的二進制數據怎樣顯示進度條!

用Progress控制項;
public void DoSth(int max, int current)
{
decimal res = (Convert.ToDecimal(current) / Convert.ToDecimal(max)) * 100;
res = Decimal.Floor(res);
this.label1.Text = current.ToString() + "/" + max.ToString();
this.prgbar.Value = Convert.ToInt32(res);
Application.DoEvents();
}
聲明相應委託,public delegate void DoSthEventHandler(int max, int current);
定義好事件,public event DoSthEventHandler OnDoSth;
OnDoSth += new DoSthEventHandler(frmGressbar.DoSth);
然後在數據傳輸的方法中觸發事件。
if (OnDoSth != null)
{
OnDoSth(this.neuSpread1_Sheet1.RowCount, i+1);
}

⑵ 自己發布的WEB在網頁上面進度條走到一半不走了 網頁打不開怎麼辦 已近試過重新發布 之前瀏覽沒任何問題

你發布到哪裡的?不行的話就完全刪除伺服器端的web文件,再重新上傳~

⑶ c# web如何實現進度條

js+div+css自定義,後台傳值給js,js動態控制div。

⑷ java web 伺服器端執行的進度條

開始頁面:start.jsp

<%@ page contentType="text/html; charset=GBK" %>
<% session.removeAttribute("task"); %>
<jsp:useBean id="task" scope="session" class="progress.TaskBean"/>
<% task.setRunning(true); %>
<% new Thread(task).start(); %>
<jsp:forward page="status.jsp"/>

狀態頁面:status.jsp
<%@ page contentType="text/html; charset=GBK" %>
<jsp:useBean id="task" scope="session" class="progress.TaskBean"/>
<HTML>
<HEAD>
<TITLE>JSP進度條</TITLE>
<% if (task.isRunning()) { %>
<script type="" LANGUAGE="JavaScript">
setTimeout("location='status.jsp'", 1000);
</script>
<% } %>
</HEAD>
<bODY bgcolor="">
<H1 ALIGN="CENTER">JSP進度條</H1>
<H2 ALIGN="CENTER">
結果: <%= task.getResult() %><BR>
<% int percent = task.getPercent(); %>
<%= percent %>%
</H2>
<TABLE WIDTH="60%" ALIGN="CENTER"
CELLPADDING=0 CELLSPACING=2>
<TR>
<% for (int i = 10; i <= percent; i += 10) { %>
<TD WIDTH="10%" height="10" BGCOLOR="red"> </TD>
<% } %>
<% for (int i = 100; i > percent; i -= 10) { %>
<TD WIDTH="10%"> </TD>
<% } %>
</TR>
</TABLE>
<TABLE WIDTH="100%" BORDER=0 CELLPADDING=0 CELLSPACING=0>
<TR>
<TD ALIGN="CENTER">
<% if (task.isRunning()) { %>
正在執行
<% } else { %>
<% if (task.isCompleted()) { %>
完成
<% } else if (!task.isStarted()) { %>
尚未開始
<% } else { %>
已停止
<% } %>
<% } %>
</TD>
</TR>
<TR>
<TD ALIGN="CENTER">
<BR>
<% if (task.isRunning()) { %>
<FORM METHOD="GET" ACTION="stop.jsp">
<INPUT TYPE="SUBMIT" ="停止">
</FORM>
<% } else { %>
<FORM METHOD="GET" ACTION="start.jsp">
<INPUT TYPE="SUBMIT" ="開始">
</FORM>
<% } %>
</TD>
</TR>
</TABLE>
</BODY></HTML>

停止頁面:stop.jsp
<%@ page contentType="text/html; charset=GBK" %>
<jsp:useBean id="task" scope="session" class="progress.TaskBean"/>
<% task.setRunning(false); %>
<jsp:forward page="status.jsp"/>

業務邏輯bean:TaskBean.java

package progress;
import java.io.Serializable;
public class TaskBean
implements Runnable, Serializable {
private int counter;
private int sum;
private boolean started;
private boolean running;
private int sleep;
public TaskBean() {
counter = 0;
sum = 0;
started = false;
running = false;
sleep = 100;
}
protected void work() {
try {
Thread.sleep(sleep);
counter++;
sum += counter;
}
catch (InterruptedException e) {
setRunning(false);
}
}
public synchronized int getPercent() {
return counter;
}
public synchronized boolean isStarted() {
return started;
}
public synchronized boolean isCompleted() {
return counter == 100;
}
public synchronized boolean isRunning() {
return running;
}
public synchronized void setRunning(boolean running) {
this.running = running;
if (running) {
started = true;
}
}
public synchronized Object getResult() {
if (isCompleted()) {
return new Integer(sum);
}
else {
return null;
}
}
public void run() {
try {
setRunning(true);
while (isRunning() && !isCompleted()) {
work();
}
}
finally {
setRunning(false);
}
}
}

⑸ javaweb 多文件上傳

用js添加div,每個div中具有一個form的表單實現上傳!

⑹ java多文件上傳顯示進度條

使用 apache fileupload ,spring MVC jquery1.6x , bootstrap 實現一個帶進度條的多文件上傳,由於fileupload 的局限,暫不能實現每個上傳文件都顯示進度條,只能實現一個總的進度條,效果如圖:

packagecom.controller;

importjava.util.List;

importjavax.servlet.http.HttpServletRequest;
importjavax.servlet.http.HttpServletResponse;
importjavax.servlet.http.HttpSession;

importorg.apache.commons.fileupload.FileItemFactory;
importorg.apache.commons.fileupload.ProgressListener;
importorg.apache.commons.fileupload.disk.DiskFileItemFactory;
importorg.apache.commons.fileupload.servlet.ServletFileUpload;
importorg.apache.log4j.Logger;
importorg.springframework.stereotype.Controller;
importorg.springframework.web.bind.annotation.RequestMapping;
importorg.springframework.web.bind.annotation.RequestMethod;
importorg.springframework.web.bind.annotation.ResponseBody;
importorg.springframework.web.servlet.ModelAndView;

@Controller
{
Loggerlog=Logger.getLogger(FileUploadController.class);

/**
*upload上傳文件
*@paramrequest
*@paramresponse
*@return
*@throwsException
*/
@RequestMapping(value="/upload.html",method=RequestMethod.POST)
publicModelAndViewupload(HttpServletRequestrequest,
HttpServletResponseresponse)throwsException{
finalHttpSessionhs=request.getSession();
ModelAndViewmv=newModelAndView();
booleanisMultipart=ServletFileUpload.isMultipartContent(request);
if(!isMultipart){
returnmv;
}
//Createafactoryfordisk-basedfileitems
FileItemFactoryfactory=newDiskFileItemFactory();

//Createanewfileuploadhandler
ServletFileUploapload=newServletFileUpload(factory);
upload.setProgressListener(newProgressListener(){
publicvoipdate(longpBytesRead,longpContentLength,intpItems){
ProcessInfopri=newProcessInfo();
pri.itemNum=pItems;
pri.readSize=pBytesRead;
pri.totalSize=pContentLength;
pri.show=pBytesRead+"/"+pContentLength+"byte";
pri.rate=Math.round(newFloat(pBytesRead)/newFloat(pContentLength)*100);
hs.setAttribute("proInfo",pri);
}
});
Listitems=upload.parseRequest(request);
//Parsetherequest
//Processtheuploadeditems
//Iteratoriter=items.iterator();
//while(iter.hasNext()){
//FileItemitem=(FileItem)iter.next();
//if(item.isFormField()){
//Stringname=item.getFieldName();
//Stringvalue=item.getString();
//System.out.println("thisiscommonfeild!"+name+"="+value);
//}else{
//System.out.println("thisisfilefeild!");
//StringfieldName=item.getFieldName();
//StringfileName=item.getName();
//StringcontentType=item.getContentType();
//booleanisInMemory=item.isInMemory();
//longsizeInBytes=item.getSize();
//FileuploadedFile=newFile("c://"+fileName);
//item.write(uploadedFile);
//}
//}
returnmv;
}


/**
*process獲取進度
*@paramrequest
*@paramresponse
*@return
*@throwsException
*/
@RequestMapping(value="/process.json",method=RequestMethod.GET)
@ResponseBody
publicObjectprocess(HttpServletRequestrequest,
HttpServletResponseresponse)throwsException{
return(ProcessInfo)request.getSession().getAttribute("proInfo");
}

classProcessInfo{
publiclongtotalSize=1;
publiclongreadSize=0;
publicStringshow="";
publicintitemNum=0;
publicintrate=0;
}

}

⑺ webuploader的進度條怎麼觸發

使用webuploader

點擊上傳按鈕,或者復制粘貼或者拖拉圖片導下面區域里都可以上傳圖片

點擊上傳,java代碼。 servlet里的dopost方法

點擊上傳後,圖片會存入你寫入的文件夾里

需要注意的是,需要修改js文件請求後台的路徑

前段代碼如下,需要源碼的可以回復。

⑻ WEB真實的進度條如何實現

我提供一個思路,用一個變數A記錄發了多少封,你每發完一封 就用A/500可以得到一個百分比,綁到UpdateProgress就可以了