Forum Moderators: phranque

Message Too Old, No Replies

Image downloaded becomes unreadable

         

MarkyA

3:46 am on Oct 30, 2015 (gmt 0)

10+ Year Member



Hi All,

I have a weird issue on my site. Currently on Live site I am using elFinder (a Web file manager) v 2.0.2. After I download an image using elFinder, the downloaded image becomes unreadable. The size of the downloaded image and the filename are identical to the copy on the server. It is just that the image cannot be read by any image viewer or manipulation application.

Some helpful details:
(1) I have used Chrome and Firefox on Ubuntu, Windows and Mac. All downloaded images from Live site are unreadable. So this cannot be a browser or OS issue.
(2) I have a Test site, where development work is done. Downloading an image using elFinder on this site is ok. Image is readable. This site is on another server. Both servers are almost identical in terms of configuration. The Live site does have a load balancer, while Test does not. All other applications and versions used on the server should be identical, such as Apache, MySQL, PHP, etc. Configuration, more or less, are off the shelf, meaning it has not been tweaked.
(3) This warning appears on Chrome - Resource interpreted as Document but transferred with MIME type application/octet-stream. But the warning does come out on both Live and Test sites.

Any help is appreciated. Thanks!


Regards,
Marky A

whitespace

11:29 am on Oct 30, 2015 (gmt 0)

10+ Year Member Top Contributors Of The Month



Are you able to view the image on the live site (by requesting by other means)?

The size of the downloaded image and the filename are identical to the copy on the server.


And the MD5 hash? Are you saying the copy on the server is OK?


...but transferred with MIME type application/octet-stream.


It should really matter, but I believe this is an "outdated" way to force a download. The resource should be sent with the correct Content-Type header and a Content-Disposition:attachment header is then used to force the download.

MarkyA

7:16 am on Nov 2, 2015 (gmt 0)

10+ Year Member



Hi,

Upon further examination, this is what I have come up with:

(1) direct download from the server of any image is ok
(2) when downloading via this elFinder web file manager, I opened the file in a hex editor and I see that there is a 0A prepended at the start of the file

Regards,
Mark

whitespace

10:30 am on Nov 2, 2015 (gmt 0)

10+ Year Member Top Contributors Of The Month



there is a 0A prepended at the start of the file


That's a linefeed character and suggests an error in the download script. An error that could have been introduced when the script was uploaded to the server... FTP'd ASCII/Binary between OS?

What OS are you using?

MarkyA

10:39 am on Nov 2, 2015 (gmt 0)

10+ Year Member



I'm aware it's a Line Feed or Carriage Return. This one is running on Linux.

Can you kindly elaborate on this one? I'm not sure I'm following you.

Thanks!

whitespace

12:07 pm on Nov 2, 2015 (gmt 0)

10+ Year Member Top Contributors Of The Month



This one is running on Linux.


And the other one?

Importantly, are you FTP'ing files between different OS? What EOL chars do your source files contain?

Many FTP clients have an ASCII transfer mode (as well as "binary") where it automatically converts EOL markers between the respective OS as the file is uploaded/downloaded. For instance, if you are developing on Windows (0D0A by default) and transferring to Linux (0A) then when transferring in ASCII mode, the line endings are converted from 0D0A to 0A. However, as you can imagine, this can break if you're not careful and you end up with a source file that is effectively double spaced (or something). If the source code is dependent on line endings then this can break the code.