Development asp code help

Discussion in 'Software' started by Hazza, 23 Aug 2004.

  1. Hazza

    Hazza What's a Dremel?

    Joined:
    25 Nov 2003
    Posts:
    467
    Likes Received:
    0
    I am writing an .asp code page to upload files to a web server. Halfway through the code I have an 'if' statement to check the size of the file, to ensure it is not too big. However, 'if' it is too big, I need some way of stopping the upload in the 'then' statement and not allowing the following code to run. Any ideas?
     
  2. webchimp

    webchimp What's a Dremel?

    Joined:
    9 Oct 2002
    Posts:
    504
    Likes Received:
    1
  3. Hazza

    Hazza What's a Dremel?

    Joined:
    25 Nov 2003
    Posts:
    467
    Likes Received:
    0
    sorry, this mite b more useful. As i was trying to find how to limit the size of the upload, i found this site and using the code:

    If Request.TotalBytes >100000 Then
    Response.Write ("<font size=""1""font face=""verdana""color=""#000000""><p align=center><br><br><hr><b>Records To big to Upload<a href=""javascript:history.go(-1)""><br><br><br>Back<hr></b>")
    else

    i built similar code into the page. but it didnt work. when uploading a large file. the response.write does work, but the upload still continues. I need some code to put after the 'then' that WILL stop the upload ( the code for the upload follows this code on the page). I was hoping for some kinda 'halt' type command which would stop anymore code being executed, but i dont know if something like that exists :sigh:

    hope thats clearer
     
  4. PaulW

    PaulW What's a Dremel?

    Joined:
    2 Feb 2004
    Posts:
    458
    Likes Received:
    0
    From what I've figured myself, although I may be wrong here...

    the ASP will only check the size once the upload is complete. You need to do some sort of client-side validation to check the size before the upload begins. From what I read its a small section of JavaScript which just does a quick check & if the size is ok, then it posts the file.

    Can't remember the code tho, but I'm sure it is out there somewhere.
     
  5. Hazza

    Hazza What's a Dremel?

    Joined:
    25 Nov 2003
    Posts:
    467
    Likes Received:
    0
    ok, cheers. i tried some stuff before the upload starts but not with javascript. ill have a look
     
  6. Hazza

    Hazza What's a Dremel?

    Joined:
    25 Nov 2003
    Posts:
    467
    Likes Received:
    0
    hmm iv had limited success.
    I found this
    and this

    its quite important that the file size is checked before the file is uploaded to me to. hmm. ill have a play around with the active X one though.
     
  7. Nedsbeds

    Nedsbeds Badger, Slime, Weasel!!

    Joined:
    16 May 2002
    Posts:
    1,972
    Likes Received:
    9
    if file is too big then
    response.end
    else
    do something else
    end if
     
  8. Hazza

    Hazza What's a Dremel?

    Joined:
    25 Nov 2003
    Posts:
    467
    Likes Received:
    0
    cheers - thats excatly what i was looking for :D
     

Share This Page