ASP Help Req
Author
Discussion

powelly

Original Poster:

490 posts

306 months

Wednesday 21st July 2004
quotequote all
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

judas

6,211 posts

283 months

Wednesday 21st July 2004
quotequote all
Do you know what the exact error code is? This will help narrow things down a bit. Have you made sure the IUSR_machinename user has write permissions for the file/folder?

powelly

Original Poster:

490 posts

306 months

Wednesday 21st July 2004
quotequote all
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

m12_nathan

5,138 posts

283 months

Wednesday 21st July 2004
quotequote all
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.

JoolzB

3,549 posts

273 months

Wednesday 21st July 2004
quotequote all
Have you declared dict somewhere else???

set dict = server.createobject("Scripting.Dictionary")

Spyke

175 posts

262 months

Wednesday 21st July 2004
quotequote all
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

judas

6,211 posts

283 months

Wednesday 21st July 2004
quotequote all
Completely OT, but Nathan - were you in Nottingham the other day? I saw a Noble just like yours with the reg N4 TH* as I was walking back to the office from lunch!

>> Edited by judas on Wednesday 21st July 18:43

PetrolTed

34,465 posts

327 months

Wednesday 21st July 2004
quotequote all
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.

m12_nathan

5,138 posts

283 months

Wednesday 21st July 2004
quotequote all
Hi Judas - wasn't me, glad to hear there are more people with both excellent taste in cars and nice names though

Ted - any chance of a link to that?

powelly

Original Poster:

490 posts

306 months

Wednesday 21st July 2004
quotequote all
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

powelly

Original Poster:

490 posts

306 months

Wednesday 21st July 2004
quotequote all
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...