Solved

Delete a file before uploading files

Posted on 2004-07-30
5
447 Views
Last Modified: 2008-01-09
My ISP has provided me with some code to upload files. Which works the first time. The second time I try to upload files it get the following error..

ABCUpload4.XField.4 error '80040050'

A Windows error - The file exists. - (0x00000050) occurred.

/partnersite/regions/EMEA/upload_success.asp, line 24


I talked to my ISP and they say the permissions are set properly. The only thing I've been able to deduce is that the myupload.dat file doesn't like to be overwritten.  How do I delete the file automatically before uploading my other files? Here is the code of the processing asp.

<%
Set theForm = Server.CreateObject("ABCUpload4.XForm")
theForm("filefield")(1).Save "myupload.dat"
%>


Thanks
0
Comment
Question by:kevinbenedict
  • 3
5 Comments
 
LVL 3

Expert Comment

by:dwaldner
ID: 11677217
<%
set fso = Server.CreateObject("Scripting.FileSystemObject")
if fso.FileExists(FILEPATH) then
          Set file = fso.GetFile(FILEPATH)
          if fso.FileExists(BACKUP_FILEPATH) then
            Set file2 = fso.GetFile(BACKUP_FILEPATH)
            file2.Delete True
            Set file2 = nothing
          End if
          file.Move BACKUP_FILEPATH
          set file = nothing
end if
set fso = Nothing
...
%>

This should shed a little bit of light on how to do what you want...this moves your file to a backup location....

This will delete the file

<%
set fso = Server.CreateObject("Scripting.FileSystemObject")
if fso.FileExists(FILEPATH) then
          Set file = fso.GetFile(FILEPATH)
          file.Delete True
          set file = nothing
end if
%>

but basically, what you want is that fso.FileExists(FilePath) method

Dan
0
 
LVL 15

Expert Comment

by:joeposter649
ID: 11677498
0
 

Author Comment

by:kevinbenedict
ID: 11677549
This is what I tried...

<%
Set theForm = Server.CreateObject("ABCUpload4.XForm")
theForm.overwrite=True
theForm("filefield")(1).Save "myupload.dat"
%>

I got the same error.

I'll go look at your link.
0
 
LVL 15

Expert Comment

by:joeposter649
ID: 11677921
Maybe you need to use server.MapPath("/myupload.dat")
0
 
LVL 15

Accepted Solution

by:
joeposter649 earned 250 total points
ID: 11679119
Or a capital O in Overwrite.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now