Design FTP file upload (ASP.NET) with ASP.NET

xiaoxiao2021-03-06  42

This version and pure front desk upload similar to the same function, just separate the code of the front and back .aspx <% @ page language = "vb" autoeventwireup = "false" code "code" code "Webform6.aspx.vb" inherits = " MyData.Webform6 "%> Webform6 </ title> <meta name =" generator "content = "Microsoft Visual Studio .NET 7.1"> <meta name = "CODE_LANGUAGE" content = "Visual Basic .NET 7.1"> <meta name = "vs_defaultClientScript" content = "JavaScript"> <meta name = "vs_targetSchema" content = "http : //schemas.microsoft.com/intellisense/ie5 "> </ head> <body ms_positioning =" gridLayout "> <ask: panel id =" fileuploadform "visible =" true "runat =" server "> <form id = "Form2" method = "post" encType = "multipart / from-data" runat = "server"> <p> <input = "Lofile" type = "file" name = "Lofile" runat = "server"> <server / P> <p> <asp: textbox id = "DIR" runat = "server"> </ asp: textbox> <br> <! - You can specify upload path -> <ask: button id = "button1" Runat = "server" text = "button"> </ asp: button> <br> </ p> </ form> </ ask: panel> <ask: panel id = "answermsg" visible = "false" runat = "server"> <asp: label id = "</p> <p>Filename "Runat =" Server "> </ asp: label> <br> <ask: label id =" fileLength "runat =" server "> </ asp: label> <br> <ask: label id =" filetype " Runat = "server"> </ ask: label> <br> </ asp: panel> </ body> </ html> .vbimports system.ioimports system.datapublic class Webform6 inherits system.web.ui.page</p> <p>#REGON "Web フォ フォ ム デザ ナ ナ 生 れ れ コ コ ド"</p> <p>'こ こ び し ​​は Web フォ フォ ム デザ で で 必 必 必 必 必 必 必 必 必. ナ<System.diagnostics.debuggerstepthrough ()> private subinitializecomponent ()</p> <p>End Sub Protected WithEvents FileUploadForm As System.Web.UI.WebControls.Panel Protected WithEvents FileName As System.Web.UI.WebControls.Label Protected WithEvents FileLength As System.Web.UI.WebControls.Label Protected WithEvents FileType As System.Web.UI .WebControls.Label Protected WithEvents AnswerMsg As System.Web.UI.WebControls.Panel Protected WithEvents loFile As System.Web.UI.HtmlControls.HtmlInputFile Protected WithEvents Button1 As System.Web.UI.WebControls.Button Protected WithEvents dir As System.Web .UI.WebControls.TextBox</p> <p>'メモ: の プレ プレ ス ホ ホ ダ Declaration は Web フォ フォ ム デザ で で 必 必 必 必 必 必 必 必. 'Removing および および および し で.. Private DesignerPlaceHolderDeclaration as System.Object</p> <p>Private Sub Page_init (Byval e as system.Object, byval e as system.eventargs) Handles mybase.init 'codegen: こ こ メソ ド ド び し フォ 必 必 必 必 す 必 必 必 必 必 す. ナ. ナ ナ.. ナ ナ ナ ナ ナ ナ 必 デザ ナ 必 必 ナ 必 デザ デザ 必 ナ デザ 必 ナ ナ ナ ナ ナ デザ 必 必 必 必 必 必 必 必 デザ 必 必 必 必 必 必 必 必 デザ デザ す す 必 デザ デザ デザ デザ デザ デザ デザ デザ デザ. デザ デザ デザ デザ デザ デザ デザ デザ デザ デザ デザ'コ コ ド ド エディ っ っ て 変 変.. くだ くだ くだ くだ くだ い っ くだ くだ い い くだ いInitializationComponent () End Sub</p> <p>#End region</p> <p>Private sub page_load (byval sender as system.Object, byval e as system.eventargs) Handles mybase.load 'ペ ペ ジ を 初 化 化 ユ ユ ザ ザ コ ド を ここ に し ま ま. ま ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユ ユEnd Sub</p> <p>Private Sub Button1_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim lstrFileName As String Dim lstrFileNamePath As String Dim lstrFileFolder As StringIf dir.Text <> "" Then 'If upload directory is empty, Use "C: /" as the default upload directory lstrfilefolder = dir.text 'get uploaded to the server name else lstrfilefolder = "c: /" end if</p> <p>Dim files as system.web.httpfilecollection = system.web.httpContext.current.request.files Dim PostedFile as system.Web.httppostedFile = files (0)</p> <p>Lstrfilename = system.io.path.GetFileName (PostedFile.FileName) 'gets the file name' Note: Lofile.postedFile.FileName Returns the file name selected by the file dialog box, which contains the file directory information</p> <p>lstrfilename = path.getFileName (lstrfilename) 'Remove directory information, return to file name</p> <p>If Directory.exists (lstrfilefolder)) THEN 'determines whether the upload directory exists, there is no existence to establish Directory.createdIRectory (LSTRFILDER) end if</p> <p>LstrfileNamePath = LSTRFILEFOLDER & LSTRFILENAME 'Upload files to server Lofile.postedFile.saveas (lstrfilenamepath)' Get upload directory and file name</p> <p>'Obtains and displays the upload properties FileName.Text = lstrFileName' FileType.Text = loFile.PostedFile.ContentType obtained file name 'type file obtained FileLength.Text = CStr (loFile.PostedFile.ContentLength)' get file length FileUploadForm.Visible = False answermsg.visible = true 'Display upload file properties</p> <p>End Sub</p> <p>END CLASS</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-67098.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="67098" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.038</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'z1TwEBvkbjArHtLMxipeKIPJr_2FrTIN5gVM2QzDKoro5YymE5bKfWHCSvZ0TVZ7O0wKVwUwsoDwDTAGmckNQQfA_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>