PDA

View Full Version : Extension validation


data387485
08-22-2009, 06:25 AM
Hi,

I'm using VT to valid extension input, and have created this to testing,


<?php require_once("WA_ValidationToolkit/WAVT_Scripts_PHP.php"); ?>
<?php require_once("WA_ValidationToolkit/WAVT_ValidatedForm_PHP.php"); ?>
<?php require_once("WA_DigitalFilePro/HelperPHP.php"); ?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if($_SERVER["REQUEST_METHOD"] == "POST"){
WA_DFP_UploadFile("WA_UploadResult1", "file", "".((isset($_POST["file"]))?$_POST["file"]:"") ."", "files/", "[FileName]", "2", "[FileName]_[Increment]", "500", "false", "0", "0");
}
?><?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$WAFV_Redirect = "";
$_SESSION['WAVT_index_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}
$WAFV_Errors = "";
$WAFV_Errors .= WAValidateFE(((isset($_POST["file"]))?$_POST["file"]:"") . "",".gif, .jpg, .jpeg, .png",true,1);

if ($WAFV_Errors != "") {
PostResult($WAFV_Redirect,$WAFV_Errors,"index");
}
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<form action="" method="post" enctype="multipart/form-data" name="upload" id="upload">
<label>
<input type="file" name="file" id="perrge" />
</label>
<label>
<input type="submit" name="submit" id="submit" value="Submit" />
</label>
</form>
<p><?php echo $WA_DFP_UploadStatus["WA_UploadResult1"]["fileExtension"]; ?></p>
</body>
</html>


But the validation doesn't work and everything gets uploaded, the
<?php echo $WA_DFP_UploadStatus["WA_UploadResult1"]["fileExtension"]; ?>

Doesn't work either.

Any ideas?

Thanks in advance.

SOJO web
08-22-2009, 01:57 PM
Sure... it appears that you placed the validation code after the digital file upload code... so the digital file upload performs the behavior well before you validate. Flip them around to be sure you validate the input first. You may also want to do client side validation for such a form, as well.

data387485
08-22-2009, 02:00 PM
Thanks for the reply.

But if I do that, nothing gets uploaded.

The client side can be implemented easily, the main one is the server side.

SOJO web
08-22-2009, 02:18 PM
When you say "nothing" gets uploaded... do you mean even when the file passes validation?

That definitely would be strange. I have been able to run server validation with no problem. Is there a chance that the code has been changed at all... like maybe a field in your form does not match up with the validation name.

The other thing to do is to check if it the validation code itself causing the problem... to do this I would put the validation code before the Digital File Pro Upload but then create a redirect on fail to see if it something getting stuck in validation.

Jason Byrnes
08-24-2009, 09:56 AM
When you apply the File Extension server Validation, Click the Lightning bolt next to Server Variable to access the Dynamic Data bindings panel. In the Bindings panel, expand the form collection. You will notice a few variables at the bottom of the form collection that have the Lightning Bolt Icon, select the "file Simple File Name variable.