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?
<?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?
at last, i nailed it down myself....the php $_Files variable will do the trick...thanx anywayz..z
ahmedsheeraz,
Please explain what your solution was for the "upload required" validation.
Thanks in advance!
Please explain what your solution was for the "upload required" validation.
Thanks in advance!
this should do it:
Max
$myfile = JRequest::getVar( 'file_field_name', array(), 'files', 'array' );//add field name here
if(!$myfile['name'])
return 'you must upload some file!';
Max
This topic is locked and no more replies can be posted.