note 33358 deleted from features.file-upload by vincent

From: Date: Thu, 11 Sep 2003 12:30:48 +0000
Subject: note 33358 deleted from features.file-upload by vincent
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-56116@lists.php.net to get a copy of this message
Note Submitter: egreene@form-genie.com ---- Save yourself and your server the trouble of uploading an invalid file type...Throw an error on the client-side using JavaScript (most people have it enabled). Example: <script language="JavaScript"> <!-- function checkForm(thisform){ if(thisform.file.value == "" || thisform.file.value == null) { alert("Please select a file to upload"); thisform.file.focus(); thisform.file.select(); return false; } else { validformFile = /(.jpg|.JPG|.gif|.GIF)$/; if(!validformFile.test(thisform.file.value)){ alert("Only PDF files are supported. Please try again"); thisform.file.focus(); thisform.file.select(); return false; } } return true; } //--> </script> <form name="newform" action="_URL_" method="post" onSubmit="return checkForm(this)" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="100000"> ... </form>

« previous php.notes (#56116) next »