Results 1 to 16 of 16

Thread: Download a file from the contao file browser

  1. #1
    User
    Join Date
    01-25-10.
    Location
    France
    Posts
    61

    Default Download a file from the contao file browser

    Hello,
    In the back end, with the administrator user I can't succeed in downloading any (csv or txt) files from the file browser.
    The files have 777 as permissions (so they are readable for all)
    The folders are not protected in the contao file browser interface
    It is possible picture files (jpg, gif) but for any text file , it is not possible

    The window for downloading the file appears,
    but a click on the downloading buttom has no effect

    I use Contao for some months and there is the first time I see that
    Could you help ?
    Thank you very much
    Sharing and growing

  2. #2
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default Re: Download a file from the contao file browser

    Which browser are you using? Does this also happen in the contao online demo?

  3. #3
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Download a file from the contao file browser

    I have had the same (for a long time) and tried to suss it with no luck, so you're not alone.
    A question - what version of apache does your server run?

  4. #4
    User
    Join Date
    01-25-10.
    Location
    France
    Posts
    61

    Default Re: Download a file from the contao file browser

    Hello Ramjet,
    here is my apache version : Apache/2.2.14 (Ubuntu)

    I made some extra tests about my problems :
    all the authorized file extension by contao (background configuration) can be downloaded : pdf xls jpg ...
    I see that these files have their own extension icon (in the pop up window and file browser)
    but not csv and txt files, perhaps it is a way ...
    but in other application that' s work even if the icon is not display near the file name

    Could you help
    Thanks
    Sharing and growing

  5. #5
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Download a file from the contao file browser

    no idea sorry.
    I thought it might be something to do with apache as i run v1.something - but it isn't.
    It has me stumped.

  6. #6
    User
    Join Date
    01-25-10.
    Location
    France
    Posts
    61

    Default Re: Download a file from the contao file browser

    Hello,
    I continue on searching about this old problem :

    I have found that :
    only the files which have a size above 4,1kb can be downloaded (with the contao file browser )...
    this is only for the 2.9.5 contao (2.9.2 is OK)

    an idea to solve this problem?
    Thanks a lot
    Sharing and growing

  7. #7
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Download a file from the contao file browser

    I can verify that - a 5kb text file downloads, the same file cut down to 3kb doesn't.
    Seems to be just ACSII files (txt,css,kml etc), not binary ones.

    Good detective work :D
    The problem is still present in Contao 2.10.2.

    I've no idea why, but the size thing should be a good clue for Leo. Maybe report this as a bug?

  8. #8
    User taca's Avatar
    Join Date
    06-20-09.
    Location
    Kyoto, Japan
    Posts
    111

    Default Re: Download a file from the contao file browser

    Hi.

    It is very interesting. I've checked on local Contao 2.9.5 with Firefox 7.0.1, capturing HTTP traffic between client and server.

    With a larger file, HTTP request and reply without cokkie and set-cookie header field:
    Code:
    GET /contao/popup.php?src=tl_files/default.css&download=1 HTTP/1.1
    Host: www.i.kisu.co.jp
    User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20100101 Firefox/7.0.1
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: ja,en-us;q=0.8,en;q=0.5,de;q=0.3
    Accept-Encoding: gzip, deflate
    Accept-Charset: ISO-2022-JP,utf-8;q=0.7,*;q=0.7
    Connection: keep-alive
    Referer: http://www.i.kisu.co.jp/contao/popup...es/default.css
    
    HTTP/1.1 200 OK
    Date: Fri, 04 Nov 2011 03:54:32 GMT
    Server: Apache/2.2.19 (Unix)
    X-Powered-By: PHP/5.3.6
    Expires: 0
    Cache-Control: must-revalidate, post-check=0, pre-check=0
    Pragma: public
    04-Nov-2011 13:54:32 GMT; path=/
    Content-Transfer-Encoding: binary
    Content-Disposition: attachment; filename="default.css"
    Content-Length: 7894
    Keep-Alive: timeout=15, max=97
    Connection: Keep-Alive
    Content-Type: text/css;charset=utf-8
    With a smaller file:
    Code:
    GET /contao/popup.php?src=tl_files/tinymce.css&download=1 HTTP/1.1
    Host: www.i.kisu.co.jp
    User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20100101 Firefox/7.0.1
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: ja,en-us;q=0.8,en;q=0.5,de;q=0.3
    Accept-Encoding: gzip, deflate
    Accept-Charset: ISO-2022-JP,utf-8;q=0.7,*;q=0.7
    Connection: keep-alive
    Referer: http://www.i.kisu.co.jp/contao/popup...es/tinymce.css
    
    HTTP/1.1 303 See Other
    Date: Fri, 04 Nov 2011 03:58:51 GMT
    Server: Apache/2.2.19 (Unix)
    X-Powered-By: PHP/5.3.6
    Expires: 0
    Cache-Control: must-revalidate, post-check=0, pre-check=0
    Pragma: public
    04-Nov-2011 13:58:51 GMT; path=/
    Content-Transfer-Encoding: binary
    Content-Disposition: attachment; filename="tinymce.css"
    Content-Length: 863
    Location: http://www.i.kisu.co.jp/contao/popup...es/tinymce.css
    Keep-Alive: timeout=15, max=100
    Connection: Keep-Alive
    Content-Type: text/css;charset=utf-8
    Difference is latter has Location header field so HTTP response changed to 303 (redirect...).
    I wish this help to fix this problem.

    Best regards.
    --
    Takahiro Kambe

  9. #9
    User
    Join Date
    01-25-10.
    Location
    France
    Posts
    61

    Default Re: Download a file from the contao file browser

    Thanks Taca for your message,

    Nevertheless, I don't see how to solve the problem.

    is it a bug inside Contao ?
    is it a parameter to modify in Apache ?
    or a problem with internet browser ?
    must all the file have a size bigger than 4Ko ?

    regards,
    Sharing and growing

  10. #10
    User taca's Avatar
    Join Date
    06-20-09.
    Location
    Kyoto, Japan
    Posts
    111

    Default Re: Download a file from the contao file browser

    Quote Originally Posted by thdelerme
    Nevertheless, I don't see how to solve the problem.

    is it a bug inside Contao ?
    Since my previous post is output from HTTP server, I think it isn't the problem of browser but Contao.

    I don't have the real solution but after I read some code in contao/popup.php:
    Code:
    // Open download dialogue
    if ($this->Input->get('download') && $this->strFile)
    {
    	$objFile = new File($this->strFile);
    
    	header('Content-Type: ' . $objFile->mime);
    	header('Content-Transfer-Encoding: binary');
    	header('Content-Disposition: attachment; filename="' . $objFile->basename . '"');
    	header('Content-Length: ' . $objFile->filesize);
    	header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    	header('Pragma: public');
    	header('Expires: 0');
    
    	$resFile = fopen(TL_ROOT . '/' . $this->strFile, 'rb');
    	fpassthru($resFile);
    	fclose($resFile);
    
    	$this->redirect(str_replace('&download=1', '', $this->Environment->request));
    }
    I quoted from latest branches/contao-2.11/contao/popup.php. Basically, above code are almost same from Contao 2.9.5.

    WIth my analyzing,
    • With not so small files, output from header() to fclose() handled as one HTTP response, and output from $this->redirect() handled another HTTP response.[/*:m:1aipnkoo]
    • With very small files, those two outputs are handled as one HTTP response.[/*:m:1aipnkoo]


    HTTP responses with my previous post would be described. I don't completely understand the purpose of $this->redirec() and it might be wrong answer.

    Best regards.
    --
    Takahiro Kambe

  11. #11
    User taca's Avatar
    Join Date
    06-20-09.
    Location
    Kyoto, Japan
    Posts
    111

    Default Re: Download a file from the contao file browser

    Hmmm,

    Code:
    // Open download dialogue
    if ($this->Input->get('download') && $this->strFile)
    {
       $objFile = new File($this->strFile);
    
       header('Content-Type: ' . $objFile->mime);
    
    ...(snip)...
    
       header('Expires: 0');
    
       $resFile = fopen(TL_ROOT . '/' . $this->strFile, 'rb');
       fpassthru($resFile);
       fclose($resFile);
    
       $this->redirect(str_replace('&download=1', '', $this->Environment->request));
    }
    Comment out last $this->redirect() line seems to solve the problem although it might take place another problem.

    Best regards.
    --
    Takahiro Kambe

  12. #12
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Download a file from the contao file browser

    Its not a browser problem, as IE, Firefox and Chrome all do this.

    One for Leo, as it needs to be corrected in the core code.
    I'll report it and refer him to this thread.

    Good work guys :D This has been annoying me for a while.

  13. #13
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Download a file from the contao file browser

    I see you've "bugged" it already, I've added to that issue.

  14. #14
    User taca's Avatar
    Join Date
    06-20-09.
    Location
    Kyoto, Japan
    Posts
    111

    Default Re: Download a file from the contao file browser

    Hi,

    I've commented to #3595 possible fix.

    Best regards.
    --
    Takahiro Kambe

  15. #15
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Download a file from the contao file browser

    awesome taca,
    works for me on 2.10.3 :D

  16. #16
    User
    Join Date
    01-25-10.
    Location
    France
    Posts
    61

    Default Re: Download a file from the contao file browser

    Thanks Taca and Ramjet,
    That is OK now

    Regards,
    Sharing and growing

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •