reading file information client side through asp p

Results 1 to 3 of 3

Thread: reading file information client side through asp p

  1. #1
    Join Date
    Dec 1969

    Default reading file information client side through asp p

    Is it possible to determine through an asp page, the size and type of files on a users computer before uploading (with asp file upload)for example if I wanted to prevent users uploading files larger than 2Mb or .zip .mp3 or .exe files for example?<BR><BR>I cant find anuthing in the FAQs<BR><BR>Would I do this check in the upload form page or on the server side page?<BR><BR>(I don&#039;t want to have a user upload a 5 Mb file then have the server side page decide its too big and then delete it)

  2. #2
    Join Date
    Dec 1969

    Default No. Period.

    If you could do that much, you could (with only a matter of permissions standing in your way) also rename and delete files.<BR><BR>If a user is dumb enough to upload 5MB--and waste a few minutes of his/her time--then too bad.<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default You can check on next page

    Depending on what you are using to upload the file<BR>Using a component or just pure asp?<BR><BR>If you are using pure asp, then on the page they are submitting the file to you can check the file size property at the beginning of the stream<BR>something like this<BR><BR> Dim File<BR> For Each File In MyUploader.Files.Items<BR> Response.Write "File Name:" & File.FileName<BR> Response.Write "File Size:" & File.FileSize<BR> Response.Write "File Type:" & File.ContentType<BR>&#039;these are the properties you can access in the stream<BR> Next<BR><BR>intS = File.FileSize<BR><BR>IF intS &#062; 25000 THEN &#039;thats 25000 bytes<BR>strError = "NoWay"<BR>ELSE<BR>strError = "OK"<BR>END IF<BR><BR>I do this for File Artisans SaFileUp component<BR><BR>intS = Upl.FileName.TotalBytes &#039;this is SaFileUp file size prop<BR>IF intS &#062; 25000 THEN<BR>strError = "SmallPic"<BR>ELSE<BR>strError = "ok"<BR>END IF<BR><BR>Select Case (strError)<BR>Case "ok"<BR><BR>IntCounter = 10<BR>str3 = upl.Form("File1").UserFilename<BR><BR>Do While Not (intCounter = 0)<BR>strTex = Len(str3)<BR>strFin = inStr(str3, ".")<BR>intCounter = strFin<BR><BR>str3 = Right(str3, strTex - strFin) &#039;this gives me file extention only<BR>strX1 = str3<BR>Loop<BR>str3 = UCase(str3) <BR>strFU1 = True<BR>Select Case (str3) &#039;change extention to all uppercase<BR>Case "JPG" &#039;Just list the only files you allow to be uploaded<BR>strExt = "jpg" <BR>Case "JPEG"<BR>strExt = "jpeg"<BR>Case "GIF"<BR>strExt = "gif"<BR>Case Else<BR>strFU1 = False &#039;No match so this file type is not wanted...<BR>END SELECT<BR><BR>IF strFU1 = False THEN<BR>&#039;File does not match the allowed file types, redirect<BR>ELSE<BR>&#039;file type is allowed, now save the file<BR>END IF<BR> <BR>You can modify any of these to the upload method you use...<BR><BR>Try it out and if you have probs come back and post some code.<BR><BR>Russell M

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts