Use ASP. NET to design FTP file upload (

Source: Internet
Author: User
Tags ftp file
<% @ Import Namespace = "System. IO" %>
<Html>
<BODY>
<Script language = "VB" RUNAT = "SERVER">
Sub UploadFile_Clicked (Sender as Object, e as EventArgs)
Dim lstrFileName as string
Dim lstrFileNamePath as string
Dim lstrFileFolder as string
'If the upload directory is empty, use "c:" as the default Upload directory.
'Get the directory name uploaded to the server
If dir. value <> "then
LstrFileFolder = dir. value
Else
LstrFileFolder = "c :"
End if
'Get the file name
LstrFileName = loFile. PostedFile. FileName
'Note: what is returned by loFile. PostedFile. FileName?
The file name selected in the file dialog box, which contains the directory information of the file.
LstrFileName = Path. GetFileName (lstrFileName)
'Remove the directory information and return the file name
'Determine whether the upload directory exists. If it does not exist, create
If (not Directory. Exists (lstrFileFolder) Then
Directory. CreateDirectory (lstrFileFolder)
End If
'Upload files to the server
LstrFileNamePath = lstrFileFolder & lstrFileName
'Get the upload directory and file name
LoFile. PostedFile. SaveAs (lstrFileNamePath)
'Obtain and display the attributes of the uploaded file
FileName. Text = lstrFileName
'Get the file name
FileType. Text = loFile. PostedFile. ContentType
'Obtain the file type
FileLength. Text = cStr (loFile. PostedFile. ContentLength)
'Get the file length
FileUploadForm. visible = false
AnswerMsg. visible = true
'Display uploaded file attributes
End sub
</SCRIPT>
<ASP: panel id = "FileUploadForm" visible = "true" runat = "server">
<Form method = "post" enctype = "multipart/form-data" runat = "server">
<H1> Welcome to ASP. NET page for file Upload Select the name of the file uploaded to the server:
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.