close ad
WARNING PC USERS: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Required file Validation problem

Thread began 4/04/2011 10:47 am by phebberd116714 | Last modified 4/05/2011 9:54 am by Jason Byrnes | 1255 views | 3 replies |

phebberd116714

Required file Validation problem

I have a form that requires a pdf file to be uploaded.

I validate by type (pdf) correctly but when I try to add a required validation, the file is not being recognized. I think I must have made an error in how I am applying the validation.

Here is the server validation:

<?php
if (isset($_POST["Insert_x"])) {
$WAFV_Redirect = "pdfFiles_Insert.php?invalid=true";
$_SESSION['WAVT_pdfFilesInsert_376_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}
$WAFV_Errors = "";
$WAFV_Errors .= WAValidateFE(((isset($_FILES["pdfUpload"]))?$_FILES["pdfUpload"]["name"]:"") . "",".pdf",false,1);
$WAFV_Errors .= WAValidateRQ(((isset($_FILES["pdfUpload"]))?$_FILES["pdfUpload"]["name"]:"") . "",".pdf",false,2);

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

Here is the file field with the validation errors:

<input type="file" name="pdfFile" id="pdfFile" />
<?php
if (ValidatedField('pdfFilesInsert_376','pdfFilesInsert_376')) {
if ((strpos((",".ValidatedField("pdfFilesInsert_376","pdfFilesInsert_376").","), "," . "1" . ",") !== false || "1" == "")) {
if (!(false)) {
?>
<br />
<span class="errorRed"><img src="images/icon-error.gif" alt="" width="16" height="14" align="baseline" />&nbsp;You can only upload PDF files.</span>
<?php //WAFV_Conditional pdfFiles_Insert.php pdfFilesInsert_376(1:)
}
}
}?>

<?php
if (ValidatedField('pdfFilesInsert_376','pdfFilesInsert_376')) {
if ((strpos((",".ValidatedField("pdfFilesInsert_376","pdfFilesInsert_376").","), "," . "2" . ",") !== false || "2" == "")) {
if (!(false)) {
?>
<br />
<span class="errorRed"><img src="images/icon-error.gif" alt="" width="16" height="14" align="baseline" />&nbsp;Please select a PDF file.</span>
<?php //WAFV_Conditional pdfFiles_Insert.php pdfFilesInsert_376(2:)
}
}
}?>

Can anyone point out what I am doing wrong.

Thanks in advance.

Sign in to reply to this post

Jason ByrnesWebAssist

this line:
$WAFV_Errors .= WAValidateRQ(((isset($_FILES["pdfUpload"]))?$_FILES["pdfUpload"]["name"]:"") . "",".pdf",false,2);


should be:
$WAFV_Errors .= WAValidateRQ(((isset($_FILES["pdfUpload"]))?$_FILES["pdfUpload"]["name"]:"") . "",false,2);



one thing confuses me in your post though; in the validation code, you are validating a file field named pdfUpload, but the file field on your page:
<input type="file" name="pdfFile" id="pdfFile" />

is named pdfFile

Sign in to reply to this post

phebberd116714

Thank you Jason,

Your changed worked perfectly.

Yes, I had made an error, the validation should have been on the field pdfFile. That's what happens when you copy code from another page and don't take care&#8230; Duh I need a brain transplant!

Sign in to reply to this post

Jason ByrnesWebAssist

No worries, glad to hear it is working.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...