Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Uploading files: preventing double upload
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Uploading files: preventing double upload

 Post Reply Post Reply Page  12>
Author
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post Topic: Uploading files: preventing double upload
    Posted: 26 October 2004 at 4:37am
I have a site where users must upload some files. Sometimes, durig the upload, some errors occurs. Although they are instructed not to do so, some users try again and again and again... (7 times was the maximum number of trys)...

Since the upload code is huge - about 2500 lines of code - it is quite difficult to creat an error handling (the code reads the file and inserts data it contain in a database).

Is there a way of grabbing the server response and if an error occur to redirect user to a page telling "There was an error, please send the file that created to the webmaster! And please, do not try to upload it again!"?
Cristian Banu
Soft 4 web
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 26 October 2004 at 5:07am

At very the top of the page put this

<% On error resume next %>

And at the bottom put this


<%

If err.Number > 0 Then

Response.redirect "error.html"

End If

On error goto 0

%>



Edited by Mart
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 26 October 2004 at 5:54am
p.s. you might want to set a cookie of there's an error and not allow the user to upload when the cookie is present
Back to Top
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post Posted: 26 October 2004 at 6:49am
< ="text/"> It doesn't work. It just skip the error and continues with the file, but is not redirecting to an error page....
Cristian Banu
Soft 4 web
Back to Top
theSCIENTIST View Drop Down
Senior Member
Senior Member


Joined: 31 July 2003
Location: United Kingdom
Status: Offline
Points: 440
Post Options Post Options   Thanks (0) Thanks(0)   Quote theSCIENTIST Quote  Post ReplyReply Direct Link To This Post Posted: 28 October 2004 at 12:29pm
The whole point of using (On Error Resume Next) is exactly that, as for the redirect to an error page, it lies with the code and how you are trapping/handling errors.

If your code is that big, you may have to seperate it to make it more manageable by using several files.

One more piece of advice, using a cookie to mark users that uploaded is good, but don't tell them, or they will just clear the cookies.
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 28 October 2004 at 12:46pm
You have to tell them really, you can't just have an error message saying "I don't want that file" when you try to upload a file... well you could, but you would get 100's of emails asking why you don't like my files
Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post Posted: 28 October 2004 at 12:48pm
2,500 lines seems rather excessive for uploading a file, you might want to look into ASPUpload, it has built in features for file duplication handling.
Back to Top
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post Posted: 28 October 2004 at 1:23pm
@TheScientis and Gullanian

The code is actually that big because I write the insertion statement  like this:

mSQL = "INSERT INTO tblAlteSituatii("
    mSQL = mSQL & "strOra,"
    mSQL = mSQL & "strSeenBy,"
    mSQL = mSQL & "strData,"
    mSQL = mSQL & "strDetalii,"
    mSQL = mSQL & "strSituatie)"

    mSQL = mSQL & "Values("
    mSQL = mSQL & "'" & Replace(thefields3(1),"'","''") & "', "
    mSQL = mSQL & "'" & Replace(Session("UserName"),"'","''") & "', "
    mSQL = mSQL & "'" & Replace(thefields3(2),"'","''") & "', "
    mSQL = mSQL & "'" & Replace(thefields3(3),"'","''") & "', "
    mSQL = mSQL & "'" & Replace(thefields3(4),"'","''") & "')"

'It executes the SQL
MyConn.Execute (mSQL)

And this is the smallest table...
The problem is not the double uploading in itself, I don't care about that, they are only small text files, but the fact that by uploading it, it will be processed twice or even more, so I end up with lots of duplicate records in the db...
That's why (this @ Mart) the error message it's OK saying "There was an error processing the file, the webmaster has been inform about it. You DON'T NEED TO UPLOAD IT AGAIN!!!"

Cristian Banu
Soft 4 web
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.