Discussion
Need a bit of free help guys...
I'm writing a page to upload piccies to a website.
Where I have marked **This Bit** below isn't working, essentially tryig to test if the file exists, and if it does delete it.. but I get a HTTP 500 error..
Everything else works fine...
Any ideas?
Thanks
Public Function saveToFile(name, path)
If dict.Exists(name) Then
Dim temp
temp = dict(name).Item("Value")
Dim fso, tst
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Dim file
if(fso.FileExists(path))=True then
**This Bit** 'fso.DeleteFile(path,1)
saveToFile = True
else
Set file = fso.CreateTextFile(path)
For tPoint = 1 to LenB(temp)
file.Write Chr(AscB(MidB(temp,tPoint,1)))
Next
file.Close
saveToFile = True
end if
Else
saveToFile = False
End If
End Function
I'm writing a page to upload piccies to a website.
Where I have marked **This Bit** below isn't working, essentially tryig to test if the file exists, and if it does delete it.. but I get a HTTP 500 error..
Everything else works fine...
Any ideas?
Thanks
Public Function saveToFile(name, path)
If dict.Exists(name) Then
Dim temp
temp = dict(name).Item("Value")
Dim fso, tst
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Dim file
if(fso.FileExists(path))=True then
**This Bit** 'fso.DeleteFile(path,1)
saveToFile = True
else
Set file = fso.CreateTextFile(path)
For tPoint = 1 to LenB(temp)
file.Write Chr(AscB(MidB(temp,tPoint,1)))
Next
file.Close
saveToFile = True
end if
Else
saveToFile = False
End If
End Function
Hi Judas..
I get a HTTP:500 error page when this happens.. so I can only assume that even though I have write permissions to actually write the file in the first place, I can't actually delete a file???? But that doesn't ring true as it is Win 2k server..
Is there any way I can trap the error to make it more meaningful?
>> Edited by powelly on Wednesday 21st July 16:28
I get a HTTP:500 error page when this happens.. so I can only assume that even though I have write permissions to actually write the file in the first place, I can't actually delete a file???? But that doesn't ring true as it is Win 2k server..
Is there any way I can trap the error to make it more meaningful?
>> Edited by powelly on Wednesday 21st July 16:28
If you've created a separate web site in IIS, it can be a right PITA to get something more useful that "HTTP 500 happened somewhere"
Here's how you do it:
- Go into IIS
- Right-click, Properties on the web site hosting your .asp file
- In Custom Errors, scroll down to HTTP Error "500;100" and click Edit Properties
- Change the Message Type to URL and the URL to "/iisHelp/common/500-100.asp"
- Ok all of that and Right-click your web site again, but choose New, Virtual directory
- Set the Alias to "IISHelp" and the Directory to "c:/winnt/help/iishelp" (assuming a default c: installation)
You're done! You should now see the verbose version of the .asp error and move on from there.
Regarding your specific problem though, it does look like the IUSR_machinename account doesn't have delete permissions on that file and/or folder. Give it Full Control just to see if that solves it, then narrow it down as much as possible.
Spyke
edited because back-slashes don't seem to come out on PH!
>> Edited by Spyke on Wednesday 21st July 18:17
Here's how you do it:
- Go into IIS
- Right-click, Properties on the web site hosting your .asp file
- In Custom Errors, scroll down to HTTP Error "500;100" and click Edit Properties
- Change the Message Type to URL and the URL to "/iisHelp/common/500-100.asp"
- Ok all of that and Right-click your web site again, but choose New, Virtual directory
- Set the Alias to "IISHelp" and the Directory to "c:/winnt/help/iishelp" (assuming a default c: installation)
You're done! You should now see the verbose version of the .asp error and move on from there.
Regarding your specific problem though, it does look like the IUSR_machinename account doesn't have delete permissions on that file and/or folder. Give it Full Control just to see if that solves it, then narrow it down as much as possible.
Spyke
edited because back-slashes don't seem to come out on PH!
>> Edited by Spyke on Wednesday 21st July 18:17
With regard to trapping errors I stumbled across a superb bit of code a while back. It's a page that replaces the standard 500 error page and records the script error in your database or sends the line at which the error occurred to you in an email. No more errors going on that you don't know about.
Thanks guys... it smells of permissions doesn't it? Didn't think windows would let you specify delete as it were..
Trouble is it's my ISP's server. Will speak to them and hopefully get someone who knows what they are talking about to check what you have suggested. They'll porbably have a policy in place to prevent 'full control'.
Yep, dict declared elsewhere.. thx joolz.
Ted, that s/w would be good as well...
>> Edited by powelly on Wednesday 21st July 21:00
Trouble is it's my ISP's server. Will speak to them and hopefully get someone who knows what they are talking about to check what you have suggested. They'll porbably have a policy in place to prevent 'full control'.
Yep, dict declared elsewhere.. thx joolz.
Ted, that s/w would be good as well...
>> Edited by powelly on Wednesday 21st July 21:00
m12_nathan said:
Go into internet explorer options and turn off show fiendly HTTP error messages in the advance tab - it'll give you the line it is erroring on.
Got the error!
Microsoft VBScript runtime error '800a0046'
Permission denied
/new/fileLoader.asp, line 69
And this is what is failing:
Set file = fso.CreateTextFile(path)
So sorted by checking if exists and deleting first using:
fso.DeleteFile path,true
It's so much easier when it isn't 1am in the morning! Thanks guys...
Gassing Station | Computers, Gadgets & Stuff | Top of Page | What's New | My Stuff


