Select files on the server side

Source: Internet
Author: User
Tags parent directory relative root directory visual studio
Server to select a file on the server side of the small program, in the server to insert the file, such as server-side has uploaded pictures, or menu management to select the file to be executed, are useful, of course, you can change it to use, it depends on your needs.

Limited to time, can not hit it made like Windows Open File window the same effect, which Netizen did, tell Ah, later I draw the time will do, I hope to progress together with you.

<%@ language=vbscript codepage= "936"%>
<% Option Explicit%>

<%
function GetFileName (strpath)
Dim filename
filename = Mid (Strpath,instrrev (strpath, "\") +1)
GetFileName = filename
End Function
%>

<HTML>
<HEAD>
<title>noteless Valley (lijun.org) Program Example </title>
<meta name= "vs_targetschema" content= "http://schemas.microsoft.com/intellisense/ie5" >
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<meta name= "generator" content= Microsoft Visual Studio.NET 7.0 >
<style type=text/css>
Body
{
font-size:16px;
Border-top-style:none;
Font-family:verdana, song body;
Border-right-style:none;
Border-left-style:none;
Background-color:white;
Border-bottom-style:none;
}
A
{
Text-decoration:none;
}
A:hover
{
Text-decoration:underline;
}
</style>

<script language=javascript>
function selfile (filename) {
Lblmsg.innertext = filename;
}
</script>
</HEAD>
<body>
<%
Dim Strsvrpath, Strcurrentdirectory
Strsvrpath = Request. QueryString ("Path")
If Strsvrpath = "" Then
Strsvrpath = Request. ServerVariables ("Script_name")
Strsvrpath = Mid (Strsvrpath,1,instrrev (Strsvrpath, "/") "Set the initial directory here, where I set the root directory
End If
Strcurrentdirectory = Server. MapPath (Strsvrpath)
Response. Write "Current directory:" & Strsvrpath & "<br>"

Dim fso, folder, subfolder, files, item
Set fso = server. CreateObject ("Scripting.FileSystemObject")
Set folder = FSO. GetFolder (Strcurrentdirectory)
Set subfolder = folder. Subfolders

If Strsvrpath <> "/" Then
Response. Write "<a href=?path=" & Mid (Strsvrpath,1,instrrev (mid Strsvrpath,1,len (Strsvrpath)-1), "/") & ">[to" Parent directory]</a> "&" <br> "
End If
For each item in subfolder
Response. Write "<a href=?path=" & Strsvrpath & GetFileName (item) & "/><font Face=wingdings>0</font > "& _
GetFileName (item) & "</a><br>"
Next

Set files = folder. Files
For each item in files
' Take absolute path
' Response. Write "<a href=javascript:selfile ('" & Strsvrpath & GetFileName (item) & _
' "'); ><font face=wingdings>3</font>" & GetFileName (item) & "</a><br>"
' Fetch filename
' Response. Write "<a href=javascript:selfile ('" & GetFileName (item) & "); ><font Face=wingdings>3</font > "& _
' GetFileName (item) & "</a><br>"
' Take a relative path relative to a directory, this example is '/myweb/'
Response. Write "<a href=javascript:selfile ('" & Replace (Strsvrpath, "/myweb/", "") & GetFileName (item) & "');> <font face=wingdings>3</font> "& _
GetFileName (item) & "</a><br>"
Next
Set fso = Nothing
%>
<p id=lblmsg></p>
</body>
</HTML>



Large-Scale Price Reduction
  • 59% Max. and 23% Avg.
  • Price Reduction for Core Products
  • Price Reduction in Multiple Regions
undefined. /
Connect with us on Discord
  • Secure, anonymous group chat without disturbance
  • Stay updated on campaigns, new products, and more
  • Support for all your questions
undefined. /
Free Tier
  • Start free from ECS to Big Data
  • Get Started in 3 Simple Steps
  • Try ECS t5 1C1G
undefined. /

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.