this.fm.params.archives is undefined
Added by Alen Nov 10 months ago
Ok as subject says: this.fm.params.archives is undefined, and i got stuck on it, i can't get toolbar nor context menu. I have searched on web, here on your site and nothing. Anyone can help?
My setup:
<link charset="utf-8" media="screen" type="text/css" href="/media/js/elrte/css/elrte.min.css" rel="stylesheet"> <link charset="utf-8" media="screen" type="text/css" href="/media/js/elfinder/css/elfinder.css" rel="stylesheet"> <script charset="utf-8" type="text/javascript" src="/media/js/jquery161.min.js"> <script src="/media/js/ui189.min.js" type="text/javascript"> <script src="/media/js/ppmenu/ppmenu/jquery.ui.prettypiemenu.min.js" type="text/javascript"> <script charset="utf-8" type="text/javascript" src="/media/js/elrte/elrte.min.js"> <script charset="utf-8" type="text/javascript" src="/media/js/elfinder/elfinder.min.js"> <script charset="utf-8" type="text/javascript" src="/media/js/elfinder/elFinder.view.js"> <script charset="utf-8" type="text/javascript" src="/media/js/elfinder/elFinder.ui.js"> <script charset="utf-8" type="text/javascript" src="/media/js/elfinder/elFinder.quickLook.js"> <script charset="utf-8" type="text/javascript" src="/media/js/elfinder/elFinder.eventsManager.js">
My client-side:
// ELRTE
var opts = {
cssClass : 'el-rte',
// lang : 'ru',
height : 450,
toolbar : 'complete',
cssfiles : ['{{ MEDIA_URL }}/js/elrte/css/elrte-inner.css'],
fmAllow : true,
fmOpen : function(callback) {
$('<div id="elfinder" />').elfinder({
url : '../../connector',
debug: true,
dialog : { width : 700, modal : true, title : 'Datoteke' }, // open in dialog window
closeOnEditorCallback : true, // close after file select
editorCallback : callback, // pass callback to file manager
});
},
}
$('#id_content').elrte(opts);
My connector:
@login_required
def connector(request):
import cgi
try:
import json
except ImportError:
import simplejson as json
import elFinder
# configure connector options
opts = {
#'root': '/home/troex/Sites/git/elfinder/files',
'root': '/Users/alennovakovic/djangoprojects/produkcijamaste/media/files',
'URL': 'http://localhost:8000/media/files/',
# other options
'debug': True,
'fileURL': True, # download files using connector, no direct urls to files
'dirSize': True,
'dotFiles': True,
'rootAlias':'Datoteke',
# 'perms': {
# 'backup': {
# 'read': True,
# 'write': False,
# 'rm': False
# },
# '^/pics': {
# 'read': True,
# 'write': False,
# 'rm': False
# }
# },
#'uploadDeny': ['image', 'application'],
'uploadAllow': ['image', 'text', 'application'],
'uploadOrder': ['deny', 'allow'],
#'disabled': ['rename', 'archive'],
'mimeDetect': 'internal',
}
# init connector and pass options
elf = elFinder.connector(opts)
# fetch only needed GET/POST parameters
httpRequest = {}
form = cgi.FieldStorage()
for field in elf.httpAllowedParameters:
if field in form:
httpRequest[field] = form.getvalue(field)
if field == 'upload[]':
upFiles = {}
cgiUploadFiles = form['upload[]']
for up in cgiUploadFiles:
if up.filename:
upFiles[up.filename] = up.file # pack dict(filename: filedescriptor)
httpRequest['upload[]'] = upFiles
# run connector with parameters
status, header, response = elf.run(httpRequest)
# get connector output and print it out
# code below is tested with apache only (maybe other server need other method?)
if status == 200:
print 'Status: 200'
elif status == 403:
print 'Status: 403'
elif status == 404:
print 'Status: 404'
if len(header) >= 1:
for h, v in header.iteritems():
print h + ': ' + v
print
if not response is None and status == 200:
# send file
if 'file' in response and isinstance(response['file'], file):
print response['file'].read()
response['file'].close()
# output json
else:
print json.dumps(response, indent = True)
return HttpResponse(json.dumps(response, indent = True))
Oh, and print out also:
{
"debug": {
"time": 0.00068593025207519531
},
"cwd": {
"write": true,
"read": true,
"hash": "04933bfa36b33dd6e694237a277899e0",
"name": "Datoteke",
"rel": "Datoteke",
"rm": false,
"date": "01 Aug 2011 23:06",
"mime": "directory",
"size": 0
},
"cdc": [
{
"write": true,
"read": true,
"url": "http://localhost:8000/media/files/.DS_Store",
"hash": "d59d9539e45e0352139dd07370fc88d8",
"name": ".DS_Store",
"rm": true,
"date": "Yesterday 23:06",
"mime": "unknown",
"size": 6148
}
]
}
Thanks in advance,
Alen
Replies (13)
RE: this.fm.params.archives is undefined
-
Added by Troex Nevelin 10 months ago
<script charset="utf-8" type="text/javascript" src="/media/js/elfinder/elfinder.min.js">
If you include the .min.js than you don't need to include any others js files for elFinder.
- OR -
<script charset="utf-8" type="text/javascript" src="/media/js/elfinder/elFinder.view.js">
<script charset="utf-8" type="text/javascript" src="/media/js/elfinder/elFinder.ui.js">
<script charset="utf-8" type="text/javascript" src="/media/js/elfinder/elFinder.quickLook.js">
<script charset="utf-8" type="text/javascript" src="/media/js/elfinder/elFinder.eventsManager.js">
...
This is development mode when you don't include elfinder.min.js and include all the other files, see src/elfinder.src.html
RE: this.fm.params.archives is undefined
-
Added by Alen Nov 10 months ago
Hi Troex,
thanks for reply, i did fix this but i still get the same error
this.fm.params.archives is undefined
the error points to this block inside elFinder.ui.js
/* disable archive command if no archivers enabled */
if (!this.fm.params.archives.length && $.inArray('archive', disabled) == -1) {
disabled.push('archive');
}
RE: this.fm.params.archives is undefined
-
Added by Troex Nevelin 10 months ago
Does it happens in elfinder.html and elfinder.src.html out of the box with default settings? What browser are you using?
RE: this.fm.params.archives is undefined
-
Added by Alen Nov 10 months ago
no, it's all fine, even though i tested phpp version and i'm configuring python/django...
so it must be because of my code ;(...
thanks again, if i find out what's wrong i'll post it back here
cheers,
Alen
RE: this.fm.params.archives is undefined
-
Added by Alen Nov 10 months ago
Ok i made it =), the error was in calling javascript libraries.
Later i have find that i have issue with form submitting as of CSRF validation, fix that also, but it might be a good idea to add in elFinder.ui.js as it was added for rails.
elFinder.ui.js
// Rails csrf meta tag (for XSS protection), see #256
var rails_csrf_token = $('meta[name=csrf-token]').attr('content');
var rails_csrf_param = $('meta[name=csrf-param]').attr('content');
And now i stumble on error once again, whenever i want to upload files post carry no data inside upload[], see the POST:
<QueryDict: {u'current': [u'17aa7a87aec5a533a4caf37a09b5cb6b'], u'cmd': [u'upload'], u'upload[]': [u'', u'']}>
So, help please :).
RE: this.fm.params.archives is undefined
-
Added by Troex Nevelin 10 months ago
Actually, python connector was written for python2.6, and looks like it working with python2.7 on my ubuntu, but I use connector.py as CGI script, I don't have a lot of knowledge in any python based frameworks. As I see in your case you have the same situation.
I cannot get to work upload with elFinder 2.x yet, I think maybe something changed in cgi python library... so what I really recommend that you write your own handling upload mechanism in connector.py, maybe without using cgi at all.
Give me some more info about OS and Python version you are using, I'll see what I can do for you
RE: this.fm.params.archives is undefined
-
Added by Alen Nov 10 months ago
Snow Leopard, Python 2.6, Django 1.2.1
Ok i thought it is something to my settings, i will take a look at upload method in elFinder.py and then i'll try to solve it.
If i do it successfully, i will write complete setting procedure for Django users, so you can publish it in documentation or in forum.
Till next time,
Alen
RE: this.fm.params.archives is undefined
-
Added by Игорь Яковлев 7 months ago
Hello!
I have the same Erorr "this.fm.params.archives is undefined", but I can fix it.
I'm dont know where is problem :(
My Html:
1 <link rel="stylesheet" type="text/css" media="screen" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/themes/smoothness/jquery-ui.css" />
2 <link rel="stylesheet" href="/media/js/elrte-1.3/css/elrte.min.css" type="text/css" media="screen" charset="utf-8">
3
4 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" ></script>
5 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js"></script>
6
7 <script src="/media/js/elrte-1.3/js/elrte.full.js" type="text/javascript" charset="utf-8"></script>
8 <script src="/media/js/elrte-1.3/js/i18n/elrte.ru.js" type="text/javascript" charset="utf-8"></script>
9
10 <script src="/media/js/elfinder-1.2/js/elfinder.full.js" type="text/javascript" charset="utf-8"></script>
11 <link rel="stylesheet" href="/media/js/elfinder-1.2/css/elfinder.css" type="text/css" media="screen" charset="utf-8">
12
13 <script type="text/javascript">
14 $(document).ready(function(){
15 $('#id_text').elrte({
16 fmOpen : function(callback) {
17 $('<div id="myelfinder"></div>').elfinder({
18 url : 'http://localhost:8000/elfinder/connector/',
19 lang : 'ru',
20 dialog : { width : 900, modal : true, title : 'Files' }, // open in dialog window
21 closeOnEditorCallback : true, // close after file select
22 editorCallback : callback // pass callback to file manager
23 })
24 }
25 })
26 })
27 </script>
And with same connector.
Alen Nov, how and where u fix this problem ?
use python 2.7 Django 1.3 on win7 and on ubuntu not working too.
RE: this.fm.params.archives is undefined
-
Added by Troex Nevelin 7 months ago
Are you using Python connector?
this.fm.params.archives is undefined check that returned JSON contains archives key in output
RE: this.fm.params.archives is undefined
-
Added by Игорь Яковлев 7 months ago
yea, i'm using python connector like, Alen Nov wrote in first message.
JSON returned:
1 Status: 200 2 Content-type: text/html 3 4 { 5 "debug": { 6 "time": 0.003000020980834961 7 }, 8 "cwd": { 9 "write": true, 10 "read": true, 11 "hash": "1f5a48da6b10f4f9afe91700a13e6776", 12 "name": "Home", 13 "rel": "Home", 14 "rm": false, 15 "date": "20 Oct 2011 14:26", 16 "mime": "directory", 17 "size": 0 18 }, 19 "cdc": [ 20 { 21 "write": true, 22 "read": true, 23 "hash": "cdd4ae2a4f2e5be0c875b8f55acb4c96", 24 "name": "ok", 25 "rm": true, 26 "date": "Today 12:28", 27 "mime": "directory", 28 "size": 0 29 }, 30 { 31 "write": true, 32 "read": true, 33 "url": "http://localhost:8000/media/js/elfinder-1.2/files/kota_v_rulon.jpg", 34 "hash": "bb43d1e4ff2ffff3c9add475f151e055", 35 "name": "kota_v_rulon.jpg", 36 "rm": true, 37 "date": "13 Jun 2011 22:35", 38 "mime": "image/pjpeg", 39 "size": 40346 40 } 41 ] 42 }
and there no key archives :(
RE: this.fm.params.archives is undefined
-
Added by Troex Nevelin 7 months ago
init=true must be in request...
Anyway this looks like a bug, python connector is my work I'll check it out and write back
RE: this.fm.params.archives is undefined
-
Added by Troex Nevelin 7 months ago
I don't see any errors in connector, thought I've made a commit to fix potential errors
Setting 'disabled': ['archive', 'extract'] in connector options will now skip archivers check at all.
Regarding to your problem, first try cleaning all elFinder cookies if this does not help, send JSON response of http://localhost:8001/cgi-bin/connector.py?cmd=open&init=true&tree=true request ?cmd=open&init=true&tree=true is necessary!
init=true is called on init and will return params
"params": {
"url": "../files",
"extract": [
"application/x-tar",
"application/x-bzip2",
"application/x-gzip",
"application/zip"
],
"dotFiles": false,
"uplMaxSize": "256M",
"archives": [
"application/x-tar",
"application/x-bzip2",
"application/x-gzip",
"application/zip"
]
You can download updated elFinder.py from https://github.com/Studio-42/elFinder/raw/1.x/src/connectors/python/elFinder.py but I'm not sure that it will help
RE: this.fm.params.archives is undefined
-
Added by Игорь Яковлев 7 months ago
I Fix it. Problem was not in connector. Connector works fine :)
My python project not use cgi, it use wsgi so this
1 form = cgi.FieldStorage()
return empty list.
I'm wrote small code for run connector on django framework:
1 def redactor(request): 2 from apps import elFinder 3 4 opts = { 5 'root': '/path/to/files', 6 'URL': 'http://localhost:8000/media/js/elfinder-1.2/files', 7 'debug': True, # send debug information 8 'dirSize': True, # calculate directory sizes 9 'dotFiles': True, # show files beginning with dot 10 'perms': { 11 '^/upload/.*': { # you can only upload into this directory 12 'read': False, 13 'write': False, 14 'rm': False 15 }, 16 'backup': { # restrict any data changes 17 'read': True, 18 'write': False, 19 'rm': False 20 }, 21 '^/secure': { # no access to this directory 22 'read': False, 23 'write': False, 24 'rm': False 25 } 26 }, 27 'uploadDeny': ['application'], # deny upload images and applications 28 'uploadAllow': ['image/png', 'image/jpeg'], # allow upload jpg and png 29 'uploadOrder': ['deny', 'allow'], 30 'mimeDetect': 'internal', 31 } 32 elf = elFinder.connector(opts) 33 # fetch only needed GET/POST parameters 34 httpRequest = {} 35 if request.method=='GET': 36 form=request.GET 37 elif request.method=='POST': 38 form=request.POST 39 for field in elf.httpAllowedParameters: 40 if field in form: 41 httpRequest[field] = form.getlist(field)[0] 42 if field == 'upload[]': 43 upFiles = {} 44 UploadFiles = request.FILES.getlist(field) 45 for up in UploadFiles: 46 if up.name: 47 upFiles[up.name] = up.file # pack dict(filename: filedescriptor) 48 httpRequest['upload[]'] = upFiles 49 50 # # run connector with parameters 51 status, header, response = elf.run(httpRequest) 52 53 # get connector output and print it out 54 55 # code below is tested with apache only (maybe other server need other method?) 56 # if status == 200: 57 # print 'Status: 200' 58 # elif status == 403: 59 # print 'Status: 403' 60 # elif status == 404: 61 # print 'Status: 404' 62 # 63 # if len(header) >= 1: 64 # for h, v in header.iteritems(): 65 # print h + ': ' + v 66 # print 67 # 68 # if not response is None and status == 200: 69 # # send file 70 # if 'file' in response and isinstance(response['file'], file): 71 # print response['file'].read() 72 # response['file'].close() 73 # # output json 74 # else: 75 # print json.dumps(response, indent = True) 76 return HttpResponse(json.dumps(response, indent = True))
I'm think it will be usefull for some who want integrate elFinde + ElRte in django project.
Thank you for help :)
(1-13/13)