array($GLOBALS['__FILES']['Filedata']['name']), 'tmp_name' => array($GLOBALS['__FILES']['Filedata']['tmp_name']), 'size' => array($GLOBALS['__FILES']['Filedata']['size']), 'type' => array($GLOBALS['__FILES']['Filedata']['type']), 'error' => array($GLOBALS['__FILES']['Filedata']['error']) ); } $cnt=count($GLOBALS['__FILES']['userfile']['name']); $err=false; $err_available=isset($GLOBALS['__FILES']['userfile']['error']); // upload files & check for errors for($i=0;$i<$cnt;$i++) { $errors[$i]=NULL; $tmp = $GLOBALS['__FILES']['userfile']['tmp_name'][$i]; $items[$i] = stripslashes($GLOBALS['__FILES']['userfile']['name'][$i]); if($err_available) $up_err = $GLOBALS['__FILES']['userfile']['error'][$i]; else $up_err=(file_exists($tmp)?0:4); $abs = get_abs_item($dir,$items[$i]); if($items[$i]=="" || $up_err==4) continue; if($up_err==1 || $up_err==2) { $errors[$i]=ext_lang::err('miscfilesize'); $err=true; continue; } if($up_err==3) { $errors[$i]=ext_lang::err('miscfilepart'); $err=true; continue; } if(!@is_uploaded_file($tmp)) { $errors[$i]=ext_lang::err('uploadfile'); $err=true; continue; } if (@$GLOBALS['ext_File']->file_exists($abs) && empty($_REQUEST['overwrite_files'])) { $errors[$i]=ext_lang::err('itemdoesexist'); $err=true; continue; } // Upload $ok = @$GLOBALS['ext_File']->move_uploaded_file($tmp, $abs); if($ok===false || PEAR::isError( $ok )) { $errors[$i]=ext_lang::err('uploadfile'); if( PEAR::isError( $ok ) ) $errors[$i].= ' ['.$ok->getMessage().']'; $err=true; continue; } else { if( !ext_isFTPMode() ) { @$GLOBALS['ext_File']->chmod( $abs, 0644 ); } } } if($err) { // there were errors $err_msg=""; for($i=0;$i<$cnt;$i++) { if($errors[$i]==NULL) continue; $err_msg .= $items[$i]." : ".$errors[$i]."\n"; } ext_Result::sendResult('upload', false, $err_msg); } ext_Result::sendResult('upload', true, ext_Lang::msg('upload_completed')); return; } ?> { "xtype": "tabpanel", "stateId": "upload_tabpanel", "activeTab": "uploadform", "dialogtitle": "", "stateful": "true", "stateEvents": ["tabchange"], "getState": function() { return { activeTab:this.items.indexOf(this.getActiveTab()) }; }, "listeners": { "resize": { "fn": function(panel) { panel.items.each( function(item) { item.setHeight(500);return true } ); } } }, "items": [ { "xtype": "swfuploadpanel", "title": "", "height": "300", "id": "swfuploader", viewConfig: { forceFit: true }, "listeners": { "allUploadsComplete": { "fn": function(panel) { datastore.reload(); panel.destroy(); Ext.getCmp("dialog").destroy(); statusBarMessage('', false ); } } }, // Uploader Params "upload_url": "", "post_params": { "": "", "": "", "session_name": "", "user_agent": "", "option": "com_extplorer", "action": "upload", "dir": datastore.directory, "requestType": "xmlhttprequest", "confirm": "true", "token": "" }, "flash_url": "/scripts/extjs3-ext/ux.swfupload/swfupload.swf", "prevent_swf_caching": "false", "file_size_limit": "B", // Custom Params "single_file_select": false, // Set to true if you only want to select one file from the FileDialog. "confirm_delete": false, // This will prompt for removing files from queue. "remove_completed": false // Remove file from grid after uploaded. }, { "xtype": "form", "autoScroll": "true", "autoHeight": "true", "id": "uploadform", "fileUpload": true, "labelWidth": 125, "url":"", "title": "", "tooltip": "'. ((get_max_file_size() / 1024) / 1024).' MB<\/strong>
' .ext_Lang::msg('max_post_size').' = '. ((get_max_upload_limit() / 1024) / 1024).' MB<\/strong>
'; ?>", "frame": true, "items": [ { "xtype": "displayfield", "value": "'. ((get_max_file_size() / 1024) / 1024).' MB<\/strong>
' .ext_Lang::msg('max_post_size').' = '. ((get_max_upload_limit() / 1024) / 1024).' MB<\/strong>
'; ?>" }, { "xtype": "checkbox", "fieldLabel": "", "name": "overwrite_files", "checked": true }], "buttons": [{ "text": "", "handler": function() { statusBarMessage( '', true ); form = Ext.getCmp("uploadform").getForm(); form.submit({ //reset: true, reset: false, success: function(form, action) { datastore.reload(); statusBarMessage( action.result.message, false, true ); Ext.getCmp("dialog").destroy(); }, failure: function(form, action) { if( !action.result ) return; Ext.MessageBox.alert('', action.result.error); statusBarMessage( action.result.error, false, false ); }, "scope": form, // add some vars to the request, similar to hidden fields "params": { "option": "com_extplorer", "action": "upload", "dir": datastore.directory, "requestType": "xmlhttprequest", "confirm": "true", "token": "" } }); } }, { "text": "", "handler": function() { Ext.getCmp("dialog").destroy(); } }] }, { "xtype": "form", "id": "transferform", "url":"", "hidden": "true", "title": "", "autoHeight": "true", "labelWidth": 225, "frame": true, "items": [ { "xtype": "checkbox", "fieldLabel": "", "name": "overwrite_files", "checked": true } ], "buttons": [{ "text": "", "handler": function() { statusBarMessage( '', true ); transfer = Ext.getCmp("transferform").getForm(); transfer.submit({ //reset: true, reset: false, success: function(form, action) { datastore.reload(); statusBarMessage( action.result.message, false, true ); Ext.getCmp("dialog").destroy(); }, failure: function(form, action) { if( !action.result ) return; Ext.MessageBox.alert('', action.result.error); statusBarMessage( action.result.error, false, false ); }, scope: transfer, // add some vars to the request, similar to hidden fields params: { "option": "com_extplorer", "action": "transfer", "dir": datastore.directory, "confirm": 'true', "token": "" } }); } },{ "text": "", "handler": function() { Ext.getCmp("dialog").destroy(); } }] }] }