I have a class
by the name of Input. Within this class
is a function
called iData. This function
is used to get file upload data, here's the function.
public static function iData($item, $spec = '')
{
if (isset($_FILES[$item])) {
if ($spec == '') {
return $_FILES[$item];
}else{
$f = $_FILES[$item];
if($f[$spec]) {
return $f[$spec];
}
}
}
return false;
}
But in my controller
(By the way I'm using the MVC
design pattern), when I tell it to move the file it doesn't. Here's my controller
's code.
if (!empty(Input::iData('file', 'name'))) {
if (is_dir('assets/')) {
if (move_uploaded_file(Input::iData('file', 'name'), 'assets/')) {
echo "File was moved!";
} else {
echo "File failed to move!";
}
}
} else {
echo "Please include a file to upload!";
}
My page echo
s, "File failed to move!". So if the directory exists and I know that the Input class
and iData function return the name, what is wrong?