使用joomla 2.5 uploader var
并且此代码在某处无法正常工作是一个错误,我的调试器无法捕获它 想知道是否有其他人有一个joomla调试表格,将解决这个问题并解决问题..
function fileUpload($max, $module_dir, $file_type, $msg){
//Retrieve file details from uploaded file, sent from upload form
$file = JRequest::getVar('image', null, 'files', 'array');
if(isset($file)){
//Clean up filename to get rid of strange characters like spaces etc
$filename = JFile::makeSafe($file['name']);
if($file['size'] > $max) $msg = JText::_('ONLY_FILES_UNDER').' '.$max;
//Set up the source and destination of the file
$src = $file['tmp_name'];
$dest = $module_dir . DS .$filename;
//First check if the file has the right extension, we need jpg only
if ($file['type'] == $file_type | | $file_type == '*') {
if ( JFile::upload($src, $dest) ) {
//Redirect to a page of your choice
$msg = JText::_('FILE_SAVE_AS').' '.$dest;
} else {
//Redirect and throw an error message
$msg = JText::_('ERROR_IN_UPLOAD');
}
} else {
//Redirect and notify user file is not right extension
$msg = JText::_('FILE_TYPE_INVALID');
}
$msg = "<script>alert('". $msg ."');</script>";
}
return $msg;
}