VBScript-How to check limit file types 
Author Message
 VBScript-How to check limit file types

Hi

Need Help! I have modified some VBScript code that
allow a user to attach a file to a email from
within a web page and it work very well, but I
would like to be able to limit the file types that
can be attached.

I have very little VB or VBScript background. Here
part of the code where I think the limiting code
should go. I would like to limit the user to
attaching only the following file types: doc txt
wpd gif jpg  and I have no idea of what to do at
this point.

The following code checks to make sure they have
type in a document/file to be attached.

 if mail.attachment.value="" then
      MsgBox "You must enter the Path and Document
Name
                   (Ex. C:\windows\test.doc)."
      exit sub
   end if

Tom Rowe



Tue, 13 Jun 2000 03:00:00 GMT  
 VBScript-How to check limit file types

Thomas,
I would try something like this:

sub check_input()

'Put all the extensions into an array
okayfiles=split("doc,wpd,gif",",")
validfile=FALSE
for each fileExt in okayfiles
  if instr(mail.attachment.value,fileExt) then
        validfile=TRUE
  end if        
next
if validfile=FALSE then
        alert " you can only send doc,gif, etc files"
else
        document.formname.submit()
end if

end sub

I hope this helps,
Heidi



Quote:
> Hi

> Need Help! I have modified some VBScript code that
> allow a user to attach a file to a email from
> within a web page and it work very well, but I
> would like to be able to limit the file types that
> can be attached.

> I have very little VB or VBScript background. Here
> part of the code where I think the limiting code
> should go. I would like to limit the user to
> attaching only the following file types: doc txt
> wpd gif jpg  and I have no idea of what to do at
> this point.

> The following code checks to make sure they have
> type in a document/file to be attached.

>  if mail.attachment.value="" then
>       MsgBox "You must enter the Path and Document
> Name
>                    (Ex. C:\windows\test.doc)."
>       exit sub
>    end if

> Tom Rowe



Thu, 15 Jun 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Check File Type

2. Size of Halftone Type 3 limited?

3. How to check for existence of a file on harddisk form OL VBscript

4. File types, and open specified file type

5. Limiting Number of Selected Check Boxes

6. Limit / check entry in inputbox

7. Predict Connections - limiting allowed connections or BeforeConnection type even

8. Data type limits function ?

9. 64K Limit for User-Defined Types?

10. User defined type limited to 64K

11. Limiting Format Type when exporting.

12. Sending the Min and Max limit in a Line type crystalreport graph

 

 
Powered by phpBB® Forum Software