View Full Version : Validate Max File Size for DFP Upload
Dave Buchholz
10-08-2009, 04:37 PM
With a nod to this thread (http://www.webassist.com/forums/showthread.php?t=1795) in the DFP forum I have a situation where I need to limit the image upload size to for the sake of argument 500kb and the most obvious way to do this is to validate it server side BUT if you have the validation routines BEFORE the upload routines the WA_UploadResult1 array has not yet been created so $WA_DFP_UploadStatus["WA_UploadResult1"]["fileSize"] is undefined and no validation takes place, having the validation routine after the upload routine means that the file has already been uploaded which defeats the object of validating it in the first place.
In DFP1 you could set maximum file sizes that made this much easier.
Is their an answer to this issue ?
Cologne
10-08-2009, 05:01 PM
I use VTK2
If you create a form with a file field. use the server validation. use to check the FILE-SIZE you can find it under the file-field.
check it against NUMBER, use intrenational and zero decimals. for 500KB you need to set max to 500000.
here is the my VTK2 line
$WAFV_Errors .= WAValidateNM(((isset($_FILES["imageName"]))?$_FILES["imageName"]["size"]:"") . "",0,1500000,0," ,",true,5);
I hope that helps.
I already wished to have that limit of file-size and image size back in the DFP2 like it was in DFP1, in this case its a step back.
Denis
Cologne
10-08-2009, 05:05 PM
screenshots
Dave Buchholz
10-08-2009, 05:10 PM
Ahhh thanks Denis I see where I was going wrong
Sades
02-22-2010, 04:40 PM
im trying to do that but with the picture width and height, but if i follow those steps when i try to submit the form im getting:
Fatal error: Call to undefined function WADFP_getImageWidth() in C:\xampp\htdocs\xxxxxxxx\admxxxxx\cat_Insert.php on line 18
and on line 18 i have
$WAFV_Errors .= WAValidateNM(WADFP_getImageWidth((isset($_FILES["foto"]))?$_FILES["foto"]:"") . "",1,500,0," ,",true,5);
do i need to do something else in order to avoid ppl uploading pictures over a size that i want?
Or is there any recepie on how to validate file size, width, height etc... cant find any specially about height and width
Jason Byrnes
02-22-2010, 05:22 PM
sounds like the require once line for the WA_DigitalFile Pro/Helper_PHP.php file is on the page after the validation toolkit code, move that file to around line 1 so the function will be declared before it is used.
Sades
02-22-2010, 06:01 PM
ok i just did that now when i press insert it just reloads the form doesnt insert just reloads the form and shows some of the required fields if empty
Sades
02-22-2010, 06:10 PM
ok i missed some things i did that to several of my insert page but checked one that was not the one that had to check for width and height the one that has to check the width and height of a picture keeps giving me the exact error moving the required <?php require_once("../WA_DigitalFilePro/HelperPHP.php"); ?> to line 2 just after the conection requirement.
Also on the insert page where i want to do a check file extension if i add this it just doesnt insert anything just reloads the page if i take out the check extension the validations work but this one has nothing about the width or height wich is 2 difrent page issues.
i added both files so techs here can have a better look seems like a bug unless im doing something wrong
Jason Byrnes
02-23-2010, 12:05 PM
the file extesnion validation is failing.
the preg_replace function is triming the period from the file externsion. change the code:
$WAFV_Errors .= WAValidateFE(((isset($_FILES["foto"]))? preg_replace('/^.*\./', '', $_FILES["foto"]["name"]) :"") . "",".gif, .jpg, .jpeg, .png",true,4);
to:
$WAFV_Errors .= WAValidateFE(((isset($_FILES["foto"]))? preg_replace('/^.*\./', '', $_FILES["foto"]["name"]) :"") . "","gif, jpg, jpeg, png",true,4);
Sades
02-23-2010, 12:23 PM
Thank you Jason will try that right now and what about the error msg if i try to validate size?
Fatal error: Call to undefined function WADFP_getImageWidth() in C:\xampp\htdocs\xxxxxxxx\admxxxxx\cat_Insert.php on line 18
i did move what you said to the first line, second line with no luck
Jason Byrnes
02-23-2010, 12:54 PM
What version of digital File pro are you using?
Sades
02-23-2010, 01:31 PM
What version of digital File pro are you using?
The one that came with my super suite Digital File Pro 1.1.3 laso planing in the future to re-buy the complete suite to get all updates but i have to finish this work in order to have the money to do that
Jason Byrnes
02-23-2010, 02:44 PM
the technique for validating the image size is not available with DFP v1, it is only available in DFP v2.
Sades
02-23-2010, 02:51 PM
the technique for validating the image size is not available with DFP v1, it is only available in DFP v2.
ok guess ill take that out then any words on this thread http://www.webassist.com/forums/showthread.php?t=10510 thanks in advance if there is any solution.
Sades
02-24-2010, 12:16 PM
the file extesnion validation is failing.
the preg_replace function is triming the period from the file externsion. change the code:
$WAFV_Errors .= WAValidateFE(((isset($_FILES["foto"]))? preg_replace('/^.*\./', '', $_FILES["foto"]["name"]) :"") . "",".gif, .jpg, .jpeg, .png",true,4);
to:
$WAFV_Errors .= WAValidateFE(((isset($_FILES["foto"]))? preg_replace('/^.*\./', '', $_FILES["foto"]["name"]) :"") . "","gif, jpg, jpeg, png",true,4);
Did not work if i place a show if next to the field no matter what extensions i add it keeps displaying that its not allowed just reloads the page with the msg, i also have try moving the upload after the validation, before the validation moved the help file to line 1 to help please.
Jason Byrnes
02-24-2010, 01:20 PM
send a copy of the page please.
Sades
02-27-2010, 09:28 PM
send a copy of the page please.
sorted out moving stuff order i have now is
security assist restricct
WA validation
WA Upload
recordset
inserts
before it had the upload after the restricct.
Thanks Jason for your time kind of forgot about this post and started to move everything, i readed on some post about moving stuff in the order would fix things
vBulletin® v3.8.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.