It looks like you're new here. If you want to get involved, click one of these buttons!
$(document).ready(function() {
$('#uploadDocument').uploadify({
'uploader': '/images/uploadify.swf',
'script': '/account/m_uploaddocument_upload',
'folder': '/account_documents/<?=$int_accountid?>',
'scriptData': {'doctype': '<?=$str_doctype?>', 'accountid': '<?=$int_accountid?>', 'userid': '<?=$_SESSION['user']['userid']?>'},
'fileDesc': 'Select Files To Upload',
'cancelImg': '/images/cancel.png',
'multi': true,
'buttonImg': '/images/upload.png',
'width': 191,
'onAllComplete': function(e, d) {
if (d.errors == 0) {
reloaddocs('reload');
$('div.uploaddocs-dialog').dialog("close");
}
else {
return false;
}
}
});
});function m_uploaddocument_upload()
{
if (!empty($_FILES)) {
$tempFile = str_replace(" ","_", $_FILES['Filedata']['tmp_name']);
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
$targetFile = str_replace(" ","_", str_replace('//','/',$targetPath) . $_FILES['Filedata']['name']);
//$fileTypes = str_replace('*.','',$_REQUEST['fileext']);
//$fileTypes = str_replace(';','|',$fileTypes);
//$typesArray = split('\|',$fileTypes);
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (!isset($fileParts['extension']))
{
$fileParts['extension'] = '';
}
//if (in_array($fileParts['extension'],$typesArray)) {
mkdir(str_replace('//','/',$targetPath), 0755, true);
if (move_uploaded_file($tempFile,$targetFile)) {
$arr_filetype = explode('_-_',$_REQUEST['doctype']);
$arr_data = array();
$arr_data['accountid'] = $_REQUEST['accountid'];
$arr_data['userid'] = $_REQUEST['userid'];
$arr_data['filename'] = $_FILES['Filedata']['name'];
$arr_data['extention'] = strtolower($fileParts['extension']);
$arr_data['path'] = $targetFile;
$arr_data['uploadeddatetime'] = date("Y-m-d H:i:s");
$arr_data['filetype'] = $arr_filetype[0];
$arr_data['description'] = $arr_filetype[1];
$this->db->insert('account_document_files', $arr_data);
$this->output->set_output("1");
}
else {
$this->output->set_output("Upload error!");
}
//} else {
// $this->output->set_output('Invalid file type.');
//}
}
}