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