Giter Club home page Giter Club logo

Comments (9)

emedchill avatar emedchill commented on July 29, 2024

This is a potential patch:

[patch]
filebrowser/sites.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/filebrowser/sites.py b/filebrowser/sites.py
index d36c4a8..193ed05 100644
--- a/filebrowser/sites.py
+++ b/filebrowser/sites.py
@@ -486,13 +486,13 @@ class FileBrowserSite(object):
return HttpResponseBadRequest('Invalid request! No filename given.')
else: # Basic (iframe) submission
# TODO: This needs some attention, do we use this at all?

  •            folder = request.POST.get('folder')
    
  •            folder = request.GET.get('folder')
             if len(request.FILES) == 1:
                 filedata = request.FILES.values()[0]
             else:
                 raise Http404('Invalid request! Multiple files included.')
             # filedata.name = convert_filename(upload.name)
    
  •            filedata.name = convert_filename(request.POST.get('file_name'))
    
  •            filedata.name = convert_filename(request.FILES.values()[0].name)
         fb_uploadurl_re = re.compile(r'^.*(%s)' % reverse("filebrowser:fb_upload", current_app=self.name))
         folder = fb_uploadurl_re.sub('', folder)
    
    [/patch]

from django-filebrowser.

italomaia avatar italomaia commented on July 29, 2024

This problem affects me also. Tested with opera browser.

from django-filebrowser.

sehmaschine avatar sehmaschine commented on July 29, 2024

issue #80 throws the same error with tests/sites.py

from django-filebrowser.

rlandry avatar rlandry commented on July 29, 2024

I am having the same issue. Useing Django 1.3, Grappelli 2.3.8, Filebrowser 3.4.3 and TinyMCE 3.5b2.

When uploading with Internet Explorer 8+, I get a "Fail" response, and no image is uploaded. Haven't tried the patch yet.

from django-filebrowser.

codenamea avatar codenamea commented on July 29, 2024

the patch is work on me. thx
I am having the same issue on IE9.

django 1.3,
Grappelli 2.3.8
django-filebrowser 3.4.3
django-tinymce 1.5.1b2

works fine on firefox and chorme.

/setting.py

MEDIA_ROOT =os.path.join(PROJECT_DIR,"media/")
MEDIA_URL = '/media/'
STATIC_ROOT = ''
STATIC_URL = '/static/'

TINYMCE_JS_URL = "/media/tiny_mce/tiny_mce.js"
TINYMCE_DEFAULT_CONFIG = {
'width':"780",
'height':"400",
'language' : "nl",
'theme': "advanced",
'theme_advanced_buttons1' : "fontsizeselect,mylistbox,mysplitbutton,bold...etc.
'theme_advanced_buttons2' : "",
'theme_advanced_buttons3' : "",
'theme_advanced_toolbar_location' : "top",
'theme_advanced_toolbar_align' : "left",
'theme_advanced_statusbar_location' : "bottom",
'theme_advanced_resizing ':'true',
}

FILEBROWSER_MEDIA_ROOT=MEDIA_ROOT
FILEBROWSER_URL_FILEBROWSER_MEDIA='/media/filebrowser/'
FILEBROWSER_DIRECTORY ="upload/"
FILEBROWSER_PATH_FILEBROWSER_MEDIA=MEDIA_ROOT+"/filebrowser/"


manage.py test filebrowser is OK

Testing started at pm2:55 ...
Creating Test for the FileBrowser site: filebrowser
Creating test database for alias 'default'...
Destroying test database for alias 'default'...

Process finished with exit code 0

from django-filebrowser.

ke1g avatar ke1g commented on July 29, 2024

I'm seeing this in an older firefox (3.0.6) with django 1.4, filebrowser 3.4.3, and grappelli 2.3.8.

The issue is that request.POST does not have 'file_name'. In fact, though this is a POST request, request.POST is empty, while request.GET does have the three csrf items plus 'folder' (sure, you can have GET parameters anytime). If there was supposed to be a 'file_name' POST parameter, it's not there. Maybe template changes not correctly tracked by Grappelli? Or maybe a difference in how newer django request stuff handles uploaded files?

The code in sites.py is using request.POST.get(), so it looks like it's in part trying to handle a missing 'file_name', but it passes the result (will be None) to convert_filename(), and, assuming one allows CONVERT_FILENAME to default to True, convert_filename() attempts to apply the string method replace to that None.

NOTE TO THOSE HAVING THIS PROBLEM: A quick fix might be to make FILEBROWSER_CONVERT_FILENAME be False in settings.py -- though I don't know what other problems may ensue from allowign space characters in filenames.

Anyway, the in memory uploaded file object "filedata" already has an '_name' attribute, also returned by the 'name' property, that looks right. Might the right thing be to use THAT name if it's there, and only try for POST['file_name'] if it's not? I guess that convert_filename() should still be applied, even if the name is already in filedata.name, since UploadedFile._set_name() leaves spaces in the filename.

But it's going to get folder wrong too, since it's looking for it in request.POST, and it's in the GET parameters. That led me to wonder whether request.is_ajax() was supposed to be returning True (it's not returning true), since then FileBrowserSite._upload_file() would be looking for 'folder' in request.GET. But len(request.FILES) is 1, and there's not 'qqfile' GET parameter, though request.FILES[0].field_name == u'qqfile'. So maybe the not ajax case needs to be more defensive, getting folder from either GET or POST parameters, wherever it shows up, and accepting the file name from wherever it shows up.

from django-filebrowser.

ke1g avatar ke1g commented on July 29, 2024

This patch seems to work for me:

--- site-packages/filebrowser/sites.py.orig     2012-08-17 17:39:27.791701904 -0400
+++ site-packages/filebrowser/sites.py  2012-08-17 18:04:50.519694279 -0400
@@ -480,17 +480,22 @@
                     filedata.name = convert_filename(request.GET['qqfile'])
                 except KeyError:
                     return HttpResponseBadRequest('Invalid request! No filename given.')
             else: # Basic (iframe) submission
                 # TODO: This needs some attention, do we use this at all?
-                folder = request.POST.get('folder')
+                folder = request.REQUEST.get('folder')
                 if len(request.FILES) == 1:
                     filedata = request.FILES.values()[0]
                 else:
                     raise Http404('Invalid request! Multiple files included.')
+                try:
+                    fname = filedata.name
+                except AttributeError:
+                    fname = request.REQUEST.get('file_name')
                 # filedata.name = convert_filename(upload.name)
-                filedata.name = convert_filename(request.POST.get('file_name'))
+                if fname:
+                    filedata.name = convert_filename(fname)

             fb_uploadurl_re = re.compile(r'^.*(%s)' % reverse("filebrowser:fb_upload", current_app=self.name))
             folder = fb_uploadurl_re.sub('', folder)

             path = os.path.join(self.directory, folder)

from django-filebrowser.

sehmaschine avatar sehmaschine commented on July 29, 2024

@ke1g filebrowser 3.4.3. is not compatible with django 1.4 (see the docs).

from django-filebrowser.

sehmaschine avatar sehmaschine commented on July 29, 2024

I'm not able to reproduce this but since we use GET with the current development version, I'm marking this as "closed". If the issue still exists with stable/3.5.x, please reopen the ticket.

from django-filebrowser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.