Hi,
I have a rather complicated page that gets a web page from our network and copies it, changes information within it and then renames it.
The problem is that sometimes it seems to work and other times it doesn't.
Here's the code:
<%@LANGUAGE = "VBSCRIPT" %>
<%Option Explicit%>
<!-- #include file = "../aspincludes/functions/checkuser.asp" //-->
<!-- #include file = "../aspincludes/Uploader/upload.asp" //-->
<%
'Function to allow different access level for each page
Usercheck(2)
' Create the FileUploader
' This starts the upload process
Dim Uploader, File, myUser, subtype, objFSO, myFile
Dim myDate
myDate = Date
myDate = Day(myDate) & "-" & Month(myDate) & "-" & Year(myDate)
Set Uploader = New FileUploader
Uploader.Upload()
subtype = Uploader.Form("subtype"
myUser = Uploader.Form("Customer"
myUser = myDate + myUser + ".htm"
If myUser = "" Then
Response.Redirect("add_" & subtype & ".asp?myError=Please%20select%20a%20user!"
End If
If Uploader.Files.Count = 0 Then
Response.Redirect("add_" & subtype & ".asp?myError=File%20upload%20error!"
Else
For Each File In Uploader.Files.Items
' Save the file
File.SaveToDisk "c:\inetpub\ & subtype & "\"
myFile = File.FileName
Next
End If
'''' Move/rename file bit
Set objFSO = CreateObject("Scripting.FileSystemObject"
Dim FromFile, ToFile, f, f2
' subtype is either quote,booking,itinerary depending on which page from.
FromFile = "c:\inetpub\ & subtype & "\" & myFile
ToFile = "c:\inetpub\ & subtype & "\" & myUser
If objFSO.FileExists(ToFile) Then
objFSO.DeleteFile ToFile
Else
objFSO.CopyFile FromFile, ToFile
objFSO.DeleteFile FromFile
End If
Do While 0 < 1
If objFSO.FileExists(ToFile) Then Exit Do
Loop
Set f = objFSO.OpenTextFile(ToFile, 1, false)
Dim fileContent
fileContent = f.ReadAll
fileContent = Replace(fileContent, "\\coronation04\qtimages\", "f.Close
Set f2 = objFSO.OpenTextFile(ToFile, 2, false)
f2.Write fileContent
f2.Close
Set objFSO = Nothing
Set f = Nothing
Set f2 = Nothing
'Now open the file and change network path of images to path a internet user can see
Response.Redirect "/cms/maincms.asp"
%>
I hope you'll be able to help me cheers.
I have a rather complicated page that gets a web page from our network and copies it, changes information within it and then renames it.
The problem is that sometimes it seems to work and other times it doesn't.
Here's the code:
<%@LANGUAGE = "VBSCRIPT" %>
<%Option Explicit%>
<!-- #include file = "../aspincludes/functions/checkuser.asp" //-->
<!-- #include file = "../aspincludes/Uploader/upload.asp" //-->
<%
'Function to allow different access level for each page
Usercheck(2)
' Create the FileUploader
' This starts the upload process
Dim Uploader, File, myUser, subtype, objFSO, myFile
Dim myDate
myDate = Date
myDate = Day(myDate) & "-" & Month(myDate) & "-" & Year(myDate)
Set Uploader = New FileUploader
Uploader.Upload()
subtype = Uploader.Form("subtype"
myUser = Uploader.Form("Customer"
myUser = myDate + myUser + ".htm"
If myUser = "" Then
Response.Redirect("add_" & subtype & ".asp?myError=Please%20select%20a%20user!"
End If
If Uploader.Files.Count = 0 Then
Response.Redirect("add_" & subtype & ".asp?myError=File%20upload%20error!"
Else
For Each File In Uploader.Files.Items
' Save the file
File.SaveToDisk "c:\inetpub\ & subtype & "\"
myFile = File.FileName
Next
End If
'''' Move/rename file bit
Set objFSO = CreateObject("Scripting.FileSystemObject"
Dim FromFile, ToFile, f, f2
' subtype is either quote,booking,itinerary depending on which page from.
FromFile = "c:\inetpub\ & subtype & "\" & myFile
ToFile = "c:\inetpub\ & subtype & "\" & myUser
If objFSO.FileExists(ToFile) Then
objFSO.DeleteFile ToFile
Else
objFSO.CopyFile FromFile, ToFile
objFSO.DeleteFile FromFile
End If
Do While 0 < 1
If objFSO.FileExists(ToFile) Then Exit Do
Loop
Set f = objFSO.OpenTextFile(ToFile, 1, false)
Dim fileContent
fileContent = f.ReadAll
fileContent = Replace(fileContent, "\\coronation04\qtimages\", "f.Close
Set f2 = objFSO.OpenTextFile(ToFile, 2, false)
f2.Write fileContent
f2.Close
Set objFSO = Nothing
Set f = Nothing
Set f2 = Nothing
'Now open the file and change network path of images to path a internet user can see
Response.Redirect "/cms/maincms.asp"
%>
I hope you'll be able to help me cheers.