Edit D:\AVAWeike\AVAWeike\AVA.ResourcesPlatform.WebUI\Control\SingleUpload.ascx
??<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SingleUpload.ascx.cs" Inherits="AVA.ResourcesPlatform.WebUI.Control.SingleUpload" %> <%-- // SUBJESTION?? using jquery-fileupload // it would suported all deveice. <div id="fileselector<%= this.UploadTag %>"> <div id="containerback<%= this.UploadTag %>"> </div> <div id="dirlijst<%= this.UploadTag %>"> </div> <div id=""> <form> <div><a href="#" onclick="document.getElementById('file<%= this.UploadTag %>').click();return false" class="btn" style="margin-top:10px;margin-bottom:10px;float:left"> <%=this.UploadControlName %></a></div> <div id="uploadlist<%= this.UploadTag %>" style="float:left;margin-left:20px; margin-top:15px;"> </div> <input type="file" id="file<%= this.UploadTag %>" multiple name="uploads[]" style="visibility:hidden;" accept="<%=this.Accept %>"> <div id="progressNumber<%= this.UploadTag %>" style="margin-left:20px;float:left;margin-top:15px;"></div> </form> <div id="progress" class="progress" style="clear:both;"> <div class="progress-bar progress-bar-success"></div> </div> </div> </div> <script type="text/javascript" src='<%= Request.WebPath()+"/Tools/jQuery-File-Upload/js/vendor/jquery.11.min.js" %>'></script> <script type="text/javascript" src='<%= Request.WebPath()+"/Tools/jQuery-File-Upload/js/vendor/jquery.ui.widget.js" %>'></script> <script type="text/javascript" src='<%= Request.WebPath()+"/Tools/jQuery-File-Upload/js/jquery.fileupload.js" %>'></script> <script> var $q = $.noConflict(true); $q(document).ready(function () { // Change this to the location of your server-side upload handler: var url = '/Test/TestUpload.aspx'; $q('#file<%= this.UploadTag %>').fileupload({ url: url, dataType: 'json', done: function (e, data) { $q.each(data.result.files, function (index, file) { $('<p/>').text(file.name).appendTo('#files'); }); }, progressall: function (e, data) { var progress = parseInt(data.loaded / data.total * 100, 10); $q('#progress .progress-bar').css( 'width', progress + '%' ); } }); }); </script> --%> <div id="fileselector<%= this.UploadTag %>"> <div id="containerback<%= this.UploadTag %>"> </div> <div id="dirlijst<%= this.UploadTag %>"> </div> <div id=""> <form name="form1" onsubmit="return false;" method="post" action="/upload" enctype="multipart/form-data" id="UploadForm<%=this.UploadTag %>"> <div><a onclick="changeOrSelectFile<%=this.UploadTag%>();" class="btn" style="margin-top:10px;margin-bottom:10px;float:left"> <%--<img src="<%= Request.WebPath()+"/Tools/AnotherUploadify/upload.png" %>" />--%><%=this.UploadControlName %></a></div> <div id="uploadlist<%= this.UploadTag %>" style="float:left;margin-left:20px; margin-top:15px;"> </div> <input type="file" id="file<%= this.UploadTag %>" multiple name="uploads[]" style="visibility: hidden" onchange="uploadchange<%= this.UploadTag %>();" accept="<%=this.Accept %>"> <input type="reset" id="reset<%= this.UploadTag %>" style="visibility: hidden"> <div id="progressNumber<%= this.UploadTag %>" style="margin-left:20px;float:left;margin-top:15px;display:none;"></div> <br/> <div class="progress progress-striped active" style="clear:both;display:none;margin-left:0px; width:60%"> <div class="bar" id="progressBar<%= this.UploadTag %>" style="font-weight:bold;"></div> </div> </form> </div> </div> <script> var FIRSTUPLOAD = -1, UPLOADING = 0, LASTUPLOAD = 1; function changeOrSelectFile<%=this.UploadTag%>() { $('#file<%= this.UploadTag %>').val(""); document.getElementById('file<%= this.UploadTag %>').click(); return false; } function uploadchange<%= this.UploadTag %>() { var input = document.getElementById("file<%= this.UploadTag %>"); if (input.value == "") { return; } var ul = document.getElementById("uploadlist<%= this.UploadTag %>"); while (ul.hasChildNodes()) { ul.removeChild(ul.firstChild); } if (input.files.length > 1) { alert("?????????????????") return; } for (var i = 0; i < input.files.length; i++) { var li = document.createElement("li"); thefilesize = input.files[i].fileSize || input.files[i].size; if (thefilesize > 1024 * 1024) { thefilesize = (Math.round(thefilesize * 100 / (1024 * 1024)) / 100).toString() + 'MB'; } else { thefilesize = (Math.round(thefilesize * 100 / 1024) / 100).toString() + 'KB'; } li.innerHTML = input.files[i].name + " " + thefilesize; ul.appendChild(li); } if (!ul.hasChildNodes()) { var li = document.createElement("li"); li.innerHTML = '?????????'; ul.appendChild(li); } var xhr = new XMLHttpRequest(); xhr.open("GET", "./file"); xhr.onload = function (e) { console.log(e); } sendRequest<%= this.UploadTag %>(); } // ie??9 ???HTML5 blob window.BlobBuilder = window.MozBlobBuilder || window.WebKitBlobBuilder || window.BlobBuilder; function sendRequest<%= this.UploadTag %>(filestat) { var file = filestat || { start: 0 }; var files1 = document.getElementById('file<%= this.UploadTag %>'); var blob = document.getElementById('file<%= this.UploadTag %>').files[0]; var BYTES_PER_CHUNK = 1048576; // 1MB chunk sizes.??????1M var SIZE = blob.size; var start = file.start; var end = BYTES_PER_CHUNK; window.uploadcounter = 0; window.uploadfilearray = []; // document.getElementById('progressNumber<%= this.UploadTag %>').innerHTML = "?????: 0 % "; $("#progressBar<%= this.UploadTag %>").css('width', 0).parent().fadeIn(); while (start < SIZE) { var chunk = blob.slice(start, end); window.uploadfilearray[window.uploadcounter] = chunk; window.uploadcounter = window.uploadcounter + 1; start = end; end = start + BYTES_PER_CHUNK; } window.uploadcounter = 0; //???????? uploadFile<%= this.UploadTag %>(window.uploadfilearray[window.uploadcounter], document.getElementById('file<%= this.UploadTag %>').files[0], {state:FIRSTUPLOAD, params: ""}); } function fileSelected<%= this.UploadTag %>() { var file = document.getElementById('fileToUpload<%= this.UploadTag %>').files[0]; if (file) { var fileSize = 0; if (file.size > 1024 * 1024) fileSize = (Math.round(file.size * 100 / (1024 * 1024)) / 100).toString() + 'MB'; else fileSize = (Math.round(file.size * 100 / 1024) / 100).toString() + 'KB'; document.getElementById('fileName<%= this.UploadTag %>').innerHTML = 'Name: ' + file.name; document.getElementById('fileSize<%= this.UploadTag %>').innerHTML = 'Size: ' + fileSize; document.getElementById('fileType<%= this.UploadTag %>').innerHTML = 'Type: ' + file.type; } } function uploadFile<%= this.UploadTag %>(blobFile, file, addOpts) { var filename = file.name; filename = encodeURIComponent(filename); var filesize = file.size; var fd = new FormData(); fd.append("fileToUpload", blobFile); var xhr = new XMLHttpRequest(); //xhr.addEventListener("load", uploadComplete<%= this.UploadTag %>, false); xhr.addEventListener("error", uploadFailed<%= this.UploadTag %>, false); xhr.addEventListener("abort", uploadCanceled<%= this.UploadTag %>, false); //var stateOpts = addOpts.state || "";// {state:FIRSTUPLOAD, params: "?????????"} //var params = addOpts.params || ""; var stateOpts = addOpts.state; switch (stateOpts) { case FIRSTUPLOAD: xhr.open("POST", "/Tools/UploadHTML5.aspx?FileName=" + filename + "&FileSize=" + filesize + "&UploadState=" + FIRSTUPLOAD); break; case LASTUPLOAD: xhr.open("POST", "/Tools/UploadHTML5.aspx?FileName=" + filename + "&FileSize=" + filesize + "&UploadState=" + LASTUPLOAD); break; case UPLOADING: xhr.open("POST", "/Tools/UploadHTML5.aspx?FileName=" + filename + "&FileSize=" + filesize + "&UploadState=" + UPLOADING); break; default: break; } xhr.onload = function (e) { window.uploadcounter = window.uploadcounter + 1; if (window.uploadfilearray.length > window.uploadcounter) { // ?????? ???loop??? //????????????????°?? if (window.uploadcounter == window.uploadfilearray.length - 1) { uploadFile<%= this.UploadTag %>(window.uploadfilearray[window.uploadcounter], document.getElementById('file<%= this.UploadTag %>').files[0], { state: LASTUPLOAD, params: "" }); } else { uploadFile<%= this.UploadTag %>(window.uploadfilearray[window.uploadcounter], document.getElementById('file<%= this.UploadTag %>').files[0], { state: UPLOADING, params: "" }); } var percentloaded2 = parseInt((window.uploadcounter / window.uploadfilearray.length) * 100); // document.getElementById('progressNumber<%= this.UploadTag %>').innerHTML = '??????: ' + percentloaded2 + ' % '; $("#progressBar<%= this.UploadTag %>").css('width', percentloaded2 + '%'); $("#progressBar<%= this.UploadTag %>").html(percentloaded2 + '%'); } else { // document.getElementById('progressNumber<%= this.UploadTag %>').innerHTML = "??????"; $("#progressBar<%= this.UploadTag %>").css('width', '100%'); $("#progressBar<%= this.UploadTag %>").html('????????'); //$("#progressBar<%= this.UploadTag %>").parent().fadeOut('slow').hide(); filename = decodeURIComponent(filename); var finalname = filename; var indexLen = finalname.lastIndexOf("."); if (indexLen != -1) { finalname = finalname.substr(0, indexLen); finalname += "<%= Session.SessionID %>"; finalname = finalname + filename.substr(indexLen, filename.length - indexLen); } else { finalname = "<%= Session.SessionID %>" + finalname; } finalname = replaceAll(finalname, " ", "_"); //???????? finalname = replaceAll(finalname, "\"", "_"); //???????????? finalname = replaceAll(finalname, "'", "_"); //???????????? finalname = replaceAll(finalname, "??", "_"); //????????????????? UploadFinished<%=this.UploadTag%>(finalname, filesize); // loadXMLDoc('./system/loaddir.php?url='+ window.currentuploaddir); } }; xhr.send(fd); } function replaceAll(src, s1, s2) { return src.replace(new RegExp(s1, "gm"), s2); } function uploadComplete<%= this.UploadTag %>(evt) { if (lastChunk<%= this.UploadTag %> == true) { } //??????????????????????????alert????""??????????????? /* This event is raised when the server send back a response */ //if (evt.target.responseText != "") { // alert(evt.target.responseText); //} } function uploadFailed<%= this.UploadTag %>(evt) { alert("??????"); } function uploadCanceled<%= this.UploadTag %>(evt) { xhr.abort(); xhr = null; //alert("The upload has been canceled by the user or the browser dropped the connection."); } </script> <%--<div id="silverlightControlHost<%= this.UploadTag %>" style="height: 50px"> <object id="MultiFileUploader<%= this.UploadTag %>" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="450" height="50"> <param name="source" value="<%= Request.WebPath() %>/Tools/SilverlightMultiFileUploader/ClientBin/mpost.SilverlightSingleFileUpload.xap" /> <param name="onerror" value="onSilverlightError<%= this.UploadTag %>" /> <param name="initParams" value="ChunkSize=122880,<%= this.InitParams %>" /> <param name="onload" value="pluginLoaded<%= this.UploadTag %>" /> <param name="background" value="#E8F6FF" /> <param name="Windowless" value="true" /> <param name="minRuntimeVersion" value="4.0.50401.0" /> <param name="autoUpgrade" value="true" /> <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50401.0" style="text-decoration: none"> <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style: none" /> </a> </object> <iframe id="_sl_historyFrame<%= this.UploadTag %>" style="visibility: hidden; height: 0; width: 0; border: 0"></iframe> </div> <script type="text/javascript"> function onSilverlightError<%= this.UploadTag %>(sender, args) { var appSource = ""; if (sender != null && sender != 0) { appSource = sender.getHost().Source; } var errorType = args.ErrorType; var iErrorCode = args.ErrorCode; var errMsg = "Unhandled Error in Silverlight 2 Application " + appSource + "\n"; errMsg += "Code: " + iErrorCode + " \n"; errMsg += "Category: " + errorType + " \n"; errMsg += "Message: " + args.ErrorMessage + " \n"; if (errorType == "ParserError") { errMsg += "File: " + args.xamlFile + " \n"; errMsg += "Line: " + args.lineNumber + " \n"; errMsg += "Position: " + args.charPosition + " \n"; } else if (errorType == "RuntimeError") { if (args.lineNumber != 0) { errMsg += "Line: " + args.lineNumber + " \n"; errMsg += "Position: " + args.charPosition + " \n"; } errMsg += "MethodName: " + args.methodName + " \n"; } alert(errMsg); throw new Error(errMsg); } var slCtl<%= this.UploadTag %> = null; if (document.getElementById("MultiFileUploader<%= this.UploadTag %>").Content == null || document.getElementById("MultiFileUploader<%= this.UploadTag %>").Content == undefined) { document.getElementById("silverlightControlHost<%= this.UploadTag %>").innerHTML = "<a href='http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50401.0' target='_blank'>???????????????????????ilverlight????????</a>"; } function pluginLoaded<%= this.UploadTag %>(sender) { slCtl<%= this.UploadTag %> = document.getElementById("MultiFileUploader<%= this.UploadTag %>"); slCtl<%= this.UploadTag %>.Content.Files.AllFilesFinished = AllFilesFinished<%= this.UploadTag %>; } function AllFilesFinished<%= this.UploadTag %>() { if (slCtl<%= this.UploadTag %> != null) { if (slCtl<%= this.UploadTag %>.Content.Files.FileList[0].StateString == "Finished") { var finalName = ""; var indexLen = slCtl<%= this.UploadTag %>.Content.Files.FileList[0].FileName.lastIndexOf("."); if (indexLen != -1) { finalName = slCtl<%= this.UploadTag %>.Content.Files.FileList[0].FileName.substr(0, indexLen); finalName += "<%= Session.SessionID %>"; finalName += slCtl<%= this.UploadTag %>.Content.Files.FileList[0].FileName.substr(indexLen, slCtl<%= this.UploadTag %>.Content.Files.FileList[0].FileName.length - indexLen); } else { finalName = "<%= Session.SessionID %>" + slCtl<%= this.UploadTag %>.Content.Files.FileList[0].FileName; } finalName = replaceAll(finalName, " ", "_"); //???????? finalName = replaceAll(finalName, "\"", "_"); //???????????? finalName = replaceAll(finalName, "'", "_"); //???????????? finalName = replaceAll(finalName, "??", "_"); //????????????????? if (typeof (UploadFinished<%= this.UploadTag %>) != "undefined") { UploadFinished<%= this.UploadTag %>(finalName, slCtl<%= this.UploadTag %>.Content.Files.FileList[0].FileSize) } } } } function replaceAll(src, s1, s2) { return src.replace(new RegExp(s1, "gm"), s2); } </script>--%> <script type="text/javascript"> //????????????????????????? <% var guid = Guid.NewGuid().ToString().Replace("-", "");%> function TestOnline<%= guid%>() { Global.HtmlControl('<%= ControlPath("TestOnline")%>', null, null, function (json) { }); } $(function () { setInterval("TestOnline<%= guid%>();", 10000); }) </script>
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de