Solved

Delete a file before uploading files

Posted on 2004-07-30
5
448 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
currencylayer API intergrate to ASP 25 66
EOF BOF error classic asp 8 43
Need help to rewrite script 3 67
ASP SQL Syntax Duplicate Key 7 93
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 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

14 Experts available now in Live!

Get 1:1 Help Now