Reads the total number of files in the file and modifies the file name as needed.
Reads the total number of files in the file and modifies the file name as needed.
The code is as follows:
<%
On Error Resume Next
Set fso = CreateObject ("Scripting.FileSystemObject")
Set Uploadfolder = fso. GetFolder (Server.MapPath ("img")) ' img For the specified folder
Set allfiles = Uploadfolder. Files
If IsEmpty (request.querystring ("act")) then
I=1
Response. Write "<table width=" "620" "border=" "1" "cellspacing=" "0" "cellpadding=" "5" "align=" "Center" ">"
For each fileitem in Allfiles
sFileName = Fileitem. Name
Response. Write "<tr>"
Response. Write "<td width=" "align=" "Center" ">" &i& "</td>"
Response. Write "<td width=" "450" ">" &sFileName& "</td>"
Response. Write "<td width=" "align=" "Center" "><a href=" "javascript:;" "onclick=" "Javascript:window.open ('? act= Edit&filename= "&sFileName&", ' NewWindow ', ' height=300, width=550, top=250, left=250, Toolbar=no, menubar =no, Scrollbars=no, resizable=no,location=n o, Status=no ') "> Edit text File </a></td>"
Response. Write "</tr>"
I=i+1
Next
Response. Write "</table>"
Response. Write "Total Files:" & (I-1)
End If
If Request ("act") = "Savefilename" Then
Set F=FSO. GetFile (server. MapPath ("img/" &request ("Ofn"))
F.name =request ("Filestr")
Set f=nothing
End If
If Request.QueryString ("act") = "edit" Then
%>
<table align= "Center" border= "1" width= "100%" height= "100%" cellspacing= "0" cellpadding= "3" bordercolor= "#6595d6" >
<form name= "Form1" method= "Post" action= "Act=savefilename&ofn=<%=request" ("filename")%> ">
<tr><th> Edit Text File </th>
</tr>
<tr><td> file Name:
<textarea name= "Filestr" style= "width:98%;height:100%;" ><%=request ("filename")%></textarea></td></tr>
<tr height= "><TD" align= "Center" >
<input type= "Submit" value= "save" ><input type= "button" value= "Close" onclick= "window.close ();" >
</td></tr>
</form>
</table>
<%
End If
%>