...but above code not working, i have also replaced if statement with JRequest::getVar('file_0')==NOFILE but it's not working also.How can i do this?"> validate empty file upload - Forums

Forums

validate empty file upload

ahmedsheeraz 02 Jun, 2009
Hi all, i have written the following code to check empty file upload in server-side validation for form field "file_0" which is an "Upload file" field:

<?php
global $mainframe;
if(JRequest::getVar('file_0')=="")
return "File upload field is required.";
?>

...but above code not working, i have also replaced if statement with JRequest::getVar('file_0')==NOFILE but it's not working also.

How can i do this?
ahmedsheeraz 02 Jun, 2009
at last, i nailed it down myself....the php $_Files variable will do the trick...thanx anywayz..z
ekull25 24 Jul, 2009
ahmedsheeraz,

Please explain what your solution was for the "upload required" validation.

Thanks in advance!
Max_admin 27 Jul, 2009
this should do it:


$myfile = JRequest::getVar( 'file_field_name', array(), 'files', 'array' );//add field name here
if(!$myfile['name'])
return 'you must upload some file!';


Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
This topic is locked and no more replies can be posted.