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?
You haven't given us much to go on there, but try these: http://www.4guysfromrolla.com/webtech/050300-1.shtml http://www.stardeveloper.com/articles/display.html?article=2003040501&page=1
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 hope thats clearer
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.
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.