Web Analytics Made Easy -
StatCounter File size query - CodingForum

Announcement

Collapse
No announcement yet.

File size query

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • File size query

    Is it possible to interogate a files size before uploading?
    I know how to find it after the act, but if there is a way to determine the size files to be uploaded before actually uploading then I'd love to know.

    TIA

    Keltoi
    ASP/VBScript
    asp vbscript
    twitter.com/justinreid

  • #2
    Are you using a third party upload component or pure vbscript code? Some components already have the feature to check the file size before uploading.
    Glenn
    vBulletin Mods That Rock!

    Comment


    • #3
      pssst Glenn, have you read the posting rules you link to:
      Signatures should be 4 lines or less
      I am the luckiest man in the world

      Comment


      • #4
        I'm using Dimac's W3 Upload, as far as I'm aware there is no such facility in this component
        asp vbscript
        twitter.com/justinreid

        Comment


        • #5
          Originally posted by Roelf
          pssst Glenn, have you read the posting rules you link to:
          Signatures should be 4 lines or less
          Thanks for correcting me

          Keltoi, look for other upload components
          Glenn
          vBulletin Mods That Rock!

          Comment


          • #6
            I'm sure that one of ASPUpload / XUpload / JUpload will exceed your requirements!

            Marcus Tucker / www / blog
            Web Analyst Programmer / Voted SPF "ASP Guru"

            Comment


            • #7
              Thanks for your sugestions, yep ASPUpload does seem to do the job.
              As I've already coded the page to check file sizes after upload, I think I'll stick with that for now.
              However, I know where to go if I should need that function in the future.

              Once angain, thanks
              asp vbscript
              twitter.com/justinreid

              Comment


              • #8
                I think that in any event, the file size will not be available client-side, but rather not until the form has actually been posted. Whatever component you are using is getting the file size from the HTTP Headers, after it has been sent across the network to the server...

                fv

                Comment


                • #9
                  Mmm, If that's the case then I'm glad I didn't shell out $149 on ASPUpload

                  Just in case anyone is reading this thread this is the method I've used to find the file size after upload:
                  Code:
                  <%
                  varPath = (Request.ServerVariables("APPL_PHYSICAL_PATH") & "files\")
                  fileName = [COLOR=darkblue]filenamevariable[/COLOR]
                  Dim objFSO
                  Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
                  Dim objFile
                  Set objFile = objFSO.GetFile(varPath & fileName)
                  varSize = objFile.Size
                  'compare file size in bytes - in this case 250Kb
                  If varSize > 256000 Then
                  	'Too big! so lets delete it
                  	objFSO.DeleteFile varPath & fileName, False
                  	'Tell the user they're very naughty!
                  	Response.Write("The File """ & fileName & """ is too big.<br>Please use your browsers back button to try again ensuring the file size is less than 250Kb.<br><br>")&_
                  	("The file size of " & fileName & " was measured at " & FormatNumber((varSize/1024),2) & "Kb (" & varSize & " bytes)")
                  	'OK, lets stop processing any more of the page before we get into anymore trouble
                  	Response.End()
                  End If
                  Set objFSO = Nothing
                  Set objFile = Nothing
                  %>
                  Most likly this can be improved on, but hey, it works
                  ----------------
                  found some more information;
                  see post on next page
                  Last edited by Keltoi; Feb 19, 2004, 12:37 PM.
                  asp vbscript
                  twitter.com/justinreid

                  Comment


                  • #10
                    Originally posted by fractalvibes
                    I think that in any event, the file size will not be available client-side, but rather not until the form has actually been posted. Whatever component you are using is getting the file size from the HTTP Headers, after it has been sent across the network to the server...
                    That's perfectly true if you're using standard form controls, however, if you're coding an IE-only solution then XUpload will restrict filesizes BEFORE upload (see bullet-point no. 15), and even better, JUpload will do it using a Java applet instead (bullet-point 11), for full cross-platform/cross-browser compatibility!!



                    (But neither are cheap, admittedly...!)
                    Marcus Tucker / www / blog
                    Web Analyst Programmer / Voted SPF "ASP Guru"

                    Comment


                    • #11
                      Good point - had forgotten about those. There I think you are talking about a client-side applet/active-x control that can help 'throttle' uploads before they occur. No doubt some $$$$...

                      fv

                      Comment


                      • #12
                        Roelf... it's not up to me... but I would give co-moderatorship to glenngv in a second.

                        I think he should be allowed as long of a signature as he wants, as long as it's not offensive to anyone.
                        Former ASP Forum Moderator - I'm back!

                        If you can teach yourself how to learn, you can learn anything. ;)

                        Comment


                        • #13
                          whammy, i agree with you. But i thought it was rather funny, the way glenn links to the rules, and then not following them himself. So i mentioned it to him in a way that was not offensive (i hope)
                          I am the luckiest man in the world

                          Comment


                          • #14
                            There is a free Pure ASP File Upload that you can try and evaluate. It can check the file size before the actual uploading occurs and most importantly it's free and with no component at all.

                            whammy, thanks for defending me

                            Edited. I first posted this without seeing Roelf's post previous to this. I found it not offensive Roelf. But it was really funny I myself broke the rule that I was trying to be linked.
                            Last edited by glenngv; Feb 19, 2004, 02:18 AM.
                            Glenn
                            vBulletin Mods That Rock!

                            Comment


                            • #15
                              Originally posted by glenngv
                              There is a free Pure ASP File Upload that you can try and evaluate. It can check the file size before the actual uploading occurs and most importantly it's free and with no component at all.
                              No it can't! As fractalvibes and I have already pointed out between us, that's not possible with the standard form controls, only with 3rd party ActiveX/Java that executes on the client!!



                              Incidentally, it is possible to do this in IE only by using the Scripting.FileSystemObject or the ADODB.Stream objects in client-side script, but in either case the user will be prompted to authorise the attempt to access the local filesystem, and if client-side scripting is disabled in the browser then the restriction code will be completely ignored! And of course, the restriction code won't work in other browsers anyway!

                              Furthermore, if he's already using a server-side upload component, why on Earth should he switch to using a pure-script solution that will place a much higher strain on the web server and make the script execute much slower?!!

                              Marcus Tucker / www / blog
                              Web Analyst Programmer / Voted SPF "ASP Guru"

                              Comment

                              Working...
                              X