Topic: Download image not working [SOLVED]

Hello,

I've just noticed that the download functionality is not working in my galleries.  I know that it used to work, but this may have been before I changed server setup - I'm not certain when it last worked.

In any case, what happens is I get a 0-length image file when I use the download icon.  Looking in the error_log for apache httpd, I see this:

PHP Warning:  readfile(/var/www/html/photos/funshoots/2016-09-15%20Melissa+Hank/images/DSCF5033.jpg): failed to open stream: No such file or directory in /var/www/html/photos/funshoots/2016-09-15 Melissa+Hank/jbcore/juicebox.php on line 21

The file we want to download is in fact there, and permissions are fine.  I think the issue is the %20 in the filename.  (I added a debug line to juicebox.php just before readfile() to print the name of the file we're readquesting, and it does show the %20 there as well).

I'm sure it must be some configuration option - perhaps a PHP config on my server?  I used to host the galleries on a Bluehost virtual server.  I am now hosting it on an AWS ec2 instance running Amazon Linux (essentially centos).

Any help appreciated.  The image I'm referring to above can be seen here: http://thomasblom.com/photos/funshoots/ … issa+Hank/

Re: Download image not working [SOLVED]

php --version on AWS:

PHP 5.6.26 (cli) (built: Oct  6 2016 19:48:12)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

on Bluehost (previous server):

PHP 5.2.17 (cgi-fcgi) (built: Sep 26 2016 15:33:30)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies


I'm sure (?) I downloaded images from galleries that had spaces in the path previously, but it sure sounds like this issue:

http://stackoverflow.com/questions/2776 … ith-spaces

Re: Download image not working [SOLVED]

The problem certainly seems to be the space in the path.
I have been able to replicate the problem using a gallery folder name containing a space.
(The Download Button works fine in the same gallery when there is no space in the path.)

One possible solution seems to be to decode the '%20' back to a ' ' in the $fileUrl variable.
Try changing line 6 of the 'juicebox.php' file from:

$fileUrl = $_GET['downloading_file'];

... to:

$fileUrl = str_replace('%20', ' ', $_GET['downloading_file']);

I'm not sure that this is the best solution but it should hopefully work.
I have notified the developers of this problem.

Please note that the line number above refers to the current version of Juicebox-Pro (v1.5.0).

The best solution would be to not use spaces in paths.
As image filenames and gallery folder names form parts of URLs when uploaded to a web server, it would be safer to use only web-safe characters. Please see section 2.3 of this document for details: https://tools.ietf.org/html/rfc3986#section-2.3

Characters that are allowed in a URI but do not have a reserved purpose are called unreserved.  These include uppercase and lowercase letters, decimal digits, hyphen, period, underscore, and tilde.

You should have no problems (with JuiceboxBuilder-Pro, your web server, FTP software or browsers) when using any or all of these unreserved characters.
(The space character is considered 'unsafe' as it needs to be encoded.)

Re: Download image not working [SOLVED]

This issue has now been fixed in Juicebox v1.5.1 which has just been released (25 August 2017).
Please see the Version History for a full list of changes.
Full instructions for upgrading can be found on the Upgrading Juicebox support page.