sorry about that...
i just applied an error handling function to see where the problem is ..
Code: Select all
function handle_file_upload($options)
{
$input = !empty($options['input']) ? $options['input'] : trigger_error('handle_file_upload: No input name specified', E_USER_ERROR);
$dest = !empty($options['dest_dir']) ? $options['dest_dir'] : trigger_error('handle_file_upload: No destination directory specified', E_USER_ERROR);
$dest_fname = !empty($options['dest_fname']) ? $options['dest_fname'] : '';
$overwrite = !empty($options['overwrite']) ? $options['overwrite'] : false;
$mode = !empty($options['mode']) ? $options['mode'] : false;
$allowed_ext = isset($options['allowed_ext']) && is_array($options['allowed_ext']) ? $options['allowed_ext'] : false;
if (!is_dir($dest))
trigger_error('handle_file_upload: Destination directory does not exist', E_USER_ERROR);
if (!isset($_FILES[$input]))
trigger_error('handle_file_upload: The input file was not found', E_USER_ERROR);
if ($_FILES[$input]['error'] > 0)
{
switch ($_FILES[$input]['error'])
{
case 1:
case 2; return array('success' => false, 'error' => 'The uploaded file was too large.');
case 3: return array('success' => false, 'error' => 'The uploaded file was only partially received.');
case 4: return array('success' => false, 'error' => 'No file was uploaded.');
case 6: return array('success' => false, 'error' => 'Missing temporary folder.');
case 7: return array('success' => false, 'error' => 'Failed to write file to disk.');
case 8: return array('success' => false, 'error' => 'Invalid extension.');
}
}
if ($allowed_ext != false && !in_array(strtolower(array_pop(explode('.', $_FILES[$input]['name']))), $allowed_ext))
return array('success' => false, 'error' => 'That file type was not allowed.');
if ($dest_fname != '')
$_FILES[$input]['name'] = $dest_fname;
$_FILES[$input]['name'] = strtolower(basename($_FILES[$input]['name']));
if (!$overwrite)
{
$fname = $_FILES[$input]['name'];
if (file_exists($dest . DIRECTORY_SEPARATOR . $fname))
{
$chunks = explode('.', $fname);
$ext = array_pop($chunks);
$fname = implode('.', $chunks);
$nr = 1;
while (file_exists($dest . DIRECTORY_SEPARATOR . $fname . '.' . $ext))
$fname = $fname . '.' . $nr++;
$_FILES[$input]['name'] = $fname . '.' . $ext;
}
}
$target = $dest . DIRECTORY_SEPARATOR . $_FILES[$input]['name'];
if (!move_uploaded_file($_FILES[$input]['tmp_name'], $target))
return array('success' => false, 'error' => 'The uploaded file could not be moved.');
if ($mode !== false)
chmod($target, $mode);
return array('success' => true, 'name' => $_FILES[$input]['name']);
}
$file = handle_file_upload(array(
'input' => 'new_pic',
'dest_dir' => dirname(__FILE__) . DIRECTORY_SEPARATOR . 'uploadz',
'dest_fname' => 'new_file.ext',
'overwrite' => true,
'mode' => 0755,
'allowed_ext' => array('jpg', 'jpeg', 'gif', 'png')
));
if ($file['success'])
echo $file['name'] . ' was uploaded';
else
echo $file['error'];
when uploading a file i get this error:
The input file was not found
any idea what does than mean??