ASP.NET File Upload Progress - OnClientProgressRefreshed function


If OnClientProgressRefreshed server-side property is set to some client-side function, this function is called with one parameter.
This parameter is an object that has the following properties:
Properties SETTINGS
propertyRequestSize numeric. The total size of sending request (on upload) in bytes.
propertyBytes numeric. Number of currently uploaded bytes.
propertyFilesCount numeric. Number of currently uploaded files.
propertyCurrentFileName string. Name of currently uploading file.
propertyUploadedList string. String with currently uploaded file items (delimited with "\n" character).

Every such item is a string with uploaded file name, its size in bytes and possibly maximum allowed file size (delimited with "/" character).
If maximum allowed file size is present in this item, it means that this file was rejected because of its too large size.

Sample

<%@ Register TagPrefix="fup" Namespace="OboutInc.FileUpload" Assembly="obout_FileUpload"%>
...
<script type="text/JavaScript">
function Refresh(info)
{
  // get element where result of refreshing should be rendered
  var place = document.getElementById("RefreshResultPlace");
 
  place.innerHTML= "uploaded "+info.Bytes+" bytes from "+info.RequestSize+"<br />"+
                            "uploading file name: <span style='color:#0000FF'>"+info.CurrentFileName+"</span><br />";

  if(info.UploadedList.length > 0)
  {
  var table = document.createElement("TABLE");
  table.border  = "0";
  table.cellPadding = "0";
  table.cellSpacing = "0";

  place.appendChild(table);

  var arr = info.UploadedList.split("\n");  // get array of file items
  for(var ind in arr)
  {
  var item =arr[ind].split("/");  // get file item array
  var row =table.insertRow(table.rows.length);
  var cell;
  var str;

  cell=row.insertCell(row.cells.length);
  cell.innerHTML= item[0]; // file name

  cell=row.insertCell(row.cells.length);

  str = "<span style='color:#0000FF'>&nbsp;&nbsp;";
  str+= (item.length >2)?"rejected":"uploaded";
  str += "</span><br/>";
  str += item[1]+"&nbsp;&nbsp;bytes"; // file size
 
// insert maximum allowed size if file was rejected
  if(item.length >2) str += "&nbsp;&nbsp;&gt;&nbsp;&nbsp;"+item[2]+"&nbsp;&nbsp;bytes";

  cell.innerHTML= str;
  }
  }
}
</script>

See also working example Client-side events handling.