Hi,
I'm using PHP 5 on Linux. I have a function that checks for file type
by doing the following:
$cmd = "file $p_input_file";
exec("$cmd 2>&1", $output, $return);
However if the file "$p_input_f ile" contains spaces, the command
doesn't work properly (I would need to insert a "\" before the space
for it to work). I figure there are probably some other characters in
the file name that would screw up the command. Is there a predefined
way of escaping the file names or do I need to just do a generic
search and replace on all the special characters I can think of?
Thanks, - Dave
I'm using PHP 5 on Linux. I have a function that checks for file type
by doing the following:
$cmd = "file $p_input_file";
exec("$cmd 2>&1", $output, $return);
However if the file "$p_input_f ile" contains spaces, the command
doesn't work properly (I would need to insert a "\" before the space
for it to work). I figure there are probably some other characters in
the file name that would screw up the command. Is there a predefined
way of escaping the file names or do I need to just do a generic
search and replace on all the special characters I can think of?
Thanks, - Dave
Comment