close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Validation show if

Thread began 2/01/2019 2:52 am by María Luisa | Last modified 2/05/2019 9:48 am by Ray Borduin | 573 views | 5 replies |

María Luisa

Validation show if

Hello
I have my upload form working: it renames the files, and uploads them when the file type and weight conditions are met and it does not upload them when it is not. But now I want that, in case the weight of the file exceeds the allowed limits, a message of Validation show if appears.

I have been consulting the forum, the tutorials of WA and I do not know what can fail in my script so that the messages do not appear when these conditions are broken.

My scripts:

----

<?php
//SCRIPTS renombrar, subir e insertar, dejar mensajes
$statusMsg = '';
function replace_specials_characters($s) {
$s = preg_replace("/á|à|â|ã|ª/","a",$s);
$s = preg_replace("/Á|À|Â|Ã/","A",$s);
$s = preg_replace("/é|è|ê/","e",$s);
$s = preg_replace("/É|È|Ê/","E",$s);
$s = preg_replace("/í|ì|î/","i",$s);
$s = preg_replace("/Í|Ì|Î/","I",$s);
$s = preg_replace("/ó|ò|ô|õ|º/","o",$s);
$s = preg_replace("/Ó|Ò|Ô|Õ/","O",$s);
$s = preg_replace("/ú|ù|û|ü/","u",$s);
$s = preg_replace("/Ú|Ù|Û/","U",$s);
$s = str_replace(" ","-",$s);
$s = str_replace("ñ","n",$s);
$s = str_replace("Ñ","N",$s);
$s = preg_replace('/[^a-zA-Z0-9_.-]/', '-', $s);
if (strpos($s,".") !== false) $s = substr($s, 0 , (strrpos($s, ".")));
return $s;
}
//campo file: V1Pru
//boton: FAIV1
//form: FAIv1Pru
//reemplazar caracteres ilegales y añadir la fecha al nombre
if(isset($_POST["FAIV1"]) && !empty($_FILES["V1Pru"]["name"])){
$dataV = date('Y-m-d');
$nombreVideo = replace_specials_characters($_FILES["V1Pru"]["name"]);
$nombreVideoBBDD = $dataV."_".$nombreVideo;
}
//campo file: V1Cert
//boton: FAIV1
//form: FAIv1Pru
if(isset($_POST["FAIV1"]) && !empty($_FILES["V1Cert"]["name"])){
$dataC = date('Y-m-d');
$nombreDoc = replace_specials_characters($_FILES["V1Cert"]["name"]);
$nombreDocBBDD = $dataC."_".$nombreDoc;
}
?>
<?php
if (isset($_POST["FAIV1"]) || isset($_POST["FAIV1_x"])) {
$WAFV_Redirect = "";
$_SESSION['WAVT_crearFAI2_506_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}
$WAFV_Errors = "";
$WAFV_Errors .= WAValidateNM(((isset($_FILES["V1Pru"]))?$_FILES["V1Pru"]["size"]:"") . "",0,52428800,0," ,",true,5);
$WAFV_Errors .= WAValidateNM(((isset($_FILES["V1Cert"]))?$_FILES["V1Cert"]["size"]:"") . "",0,12582912,0," ,",true,5);
if ($WAFV_Errors != "") {
PostResult($WAFV_Redirect,$WAFV_Errors,"crearFAI2_506");
}
}
?>
<?php
//*****UPLOAD VIDEO*****///
// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "__02_video_pru/",
'FileName' => "$nombreVideoBBDD",
'DefaultFileName' => "",
'ResizeType' => "0",
'ResizeWidth' => "0",
'ResizeHeight' => "0",
'ResizeFillColor' => "" );
// WA_UploadResult1_1 End
// WA_UploadResult1 Params End?>
<?php
// WA_UploadResult2 Params Start
$WA_UploadResult2_Params = array();
// WA_UploadResult2_1 Start
$WA_UploadResult2_Params["WA_UploadResult2_1"] = array(
'UploadFolder' => "__03_pru_cert/",
'FileName' => "$nombreDocBBDD",
'DefaultFileName' => "",
'ResizeType' => "0",
'ResizeWidth' => "0",
'ResizeHeight' => "0",
'ResizeFillColor' => "" );
// WA_UploadResult2_1 End
// WA_UploadResult2 Params End
?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if(isset($_POST["FAIV1"]) || isset($_POST["FAIV1_x"])){
WA_DFP_UploadFiles("WA_UploadResult1", "V1Pru", "2", "$nombreVideoBBDD", "false", $WA_UploadResult1_Params);
}
?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult2");
if(isset($_POST["FAIV1"]) || isset($_POST["FAIV1_x"])){
WA_DFP_UploadFiles("WA_UploadResult2", "V1Cert", "2", "$nombreDocBBDD", "false", $WA_UploadResult2_Params);
}
?>

----

My form:

----
<form method="post" action="" name="FAIv1Pru" id="FAIv1Pru" enctype="multipart/form-data">

<label for="V1Date" style="color:#4437A3; font-weight:800;">Indicar fecha del vídeo 1</label>
<input type="text" class="form-control" name="V1Date" placeholder="aaaa-mm-dd" required>
<input type="hidden" name="MAX_FILE_SIZE" value="52428800" />
<!--upload video 1-->
<label for="V1Pru" style="color:#4437A3; font-weight:800;">Subir vídeo Ensayo de Prueba</label>
<?php
if (ValidatedField('crearFAI2_506','crearFAI2_506')) {
if ((strpos((",".ValidatedField("crearFAI2_506","crearFAI2_506").","), "," . "1" . ",") !== false || "1" == "")) {
if (!(false)) {
?>
<span style="color:#ffffff; background-color:#ff0000; padding:4px; text-align:center;"> El tamaño de su documento debe ser inferior a 50 MB. Comprímalo. </span>
<?php //WAFV_Conditional crear_FAI_2.php crearFAI2_506(1:)
}
}
}?>
<input type="file" name="V1Pru" id="V1Pru" accept="video/mp4,video/x-m4v,video/*" >
<!--upload cert 1-->
<label for="V1Cert" style="color:#4437A3; font-weight:800;">Subir certificado Ensayo de Prueba</label>
<?php
if (ValidatedField('crearFAI2_506','crearFAI2_506')) {
if ((strpos((",".ValidatedField("crearFAI2_506","crearFAI2_506").","), "," . "2" . ",") !== false || "2" == "")) {
if (!(false)) {
?>
<span style="color:#ffffff; background-color:#ff0000; padding:4px; text-align:center;"> El tamaño de su documento debe ser inferior a 12 MB. Comprímalo. </span>
<?php //WAFV_Conditional crear_FAI_2.php crearFAI2_506(2:)
}
}
}?>
<input type="file" class="form-control-file" id="V1Cert" name="V1Cert" accept=".doc, .DOC, .docx, .DOCX">
<input type="submit" value="Subir vídeo Ensayo de Prueba y su documentación" name="FAIV1" style="width:100%; background-color:#1837A3; color:#ffffff; padding:8px;">
</form>


----

Does anyone have an idea about what is wrong?

Thank you

Sign in to reply to this post

Ray BorduinWebAssist

It looks like there is an issue with your form validation... you have:

$WAFV_Errors .= WAValidateNM(((isset($_FILES["V1Pru"]))?$_FILES["V1Pru"]["size"]:"") . "",0,52428800,0," ,",true,5);
$WAFV_Errors .= WAValidateNM(((isset($_FILES["V1Cert"]))?$_FILES["V1Cert"]["size"]:"") . "",0,12582912,0," ,",true,5);

The last argument is the identifier... so you have them both set to: 5

They need to be unique and match the show IF code.... your show if code looks like it uses identifiers "1" and "2", so the code should be:

$WAFV_Errors .= WAValidateNM(((isset($_FILES["V1Pru"]))?$_FILES["V1Pru"]["size"]:"") . "",0,52428800,0," ,",true,1);
$WAFV_Errors .= WAValidateNM(((isset($_FILES["V1Cert"]))?$_FILES["V1Cert"]["size"]:"") . "",0,12582912,0," ,",true,2);

Sign in to reply to this post
Did this help? Tips are appreciated...

María Luisa

I still have the problem

Hello Ray, thanks for answering.

The truth is that I still have the problem.

I have updated my validation script as well:

----

<?php
if (isset($_POST["FAIV1"]) || isset($_POST["FAIV1_x"])) {
$WAFV_Redirect = "";
$_SESSION['WAVT_crearFAI2_506_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}
$WAFV_Errors = "";
$WAFV_Errors .= WAValidateNM(((isset($_FILES["V1Pru"]))?$_FILES["V1Pru"]["size"]:"") . "",100,52428800,0," ,",true,1);
$WAFV_Errors .= WAValidateNM(((isset($_FILES["V1Cert"]))?$_FILES["V1Cert"]["size"]:"") . "",10,12582912,0," ,",true,2);

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

----

The validation show if they are placed in two span tags like this:

----

<span style="color:#ffffff; background-color:#ff0000; padding:4px; text-align:center;"> El tamaño de su documento debe ser inferior a 50 MB. Comprímalo. </span>
<?php //WAFV_Conditional crear_FAI_2.php crearFAI2_506(1:)
}
}
}?>

<span style="color:#ffffff; background-color:#ff0000; padding:4px; text-align:center;"> El tamaño de su documento debe ser inferior a 12 MB. Comprímalo. </span>
<?php //WAFV_Conditional crear_FAI_2.php crearFAI2_506(2:)
}
}
}?>

---

And it still happens that if the condition is met (the size of the files is less than required) the files go up and if it is not met they do not go up, although in this case they do not show the error messages to warn the user that they need to compress them, it's what I want...

Could it be because my name change script interferes to remove particular characters from my language and add the date to the name?

Can you or someone give me a clue?

Thank you

Sign in to reply to this post

Ray BorduinWebAssist

Please attach the entire page and I can open it in Dreamweaver and take a look.

Sign in to reply to this post
Did this help? Tips are appreciated...

María Luisa

Hi Ray
Thank you very much for looking at the file.

A greeting

Attached Files
crear_FAI_2.php
Sign in to reply to this post

Ray BorduinWebAssist

It appears correct to me. Can you send me FTP access and a URL so I can debug it... maybe session variables aren't working properly on your site?

Sign in to reply to this post
Did this help? Tips are appreciated...

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...