Php photo gallery TWG | JFUploader | TWG Flash upload | WFU | Forum
https://tinywebgallery.com/forum/

image.php
https://tinywebgallery.com/forum/viewtopic.php?f=1&t=2467
Page 1 of 1

Author:  simon_72 [ 16. Mar 2010, 09:08 ]
Post subject:  image.php

Hi,

I have made a image.php to echo the directory and image so download is possible since i like the lightbox feature. For some reason though, when the image has a space in the name (like DSC_3333 (FILEminimizer) it replaces the space with a + and so the link doesnt work. If you change the link manually to %20 then it works fine. Is there a way to change this?

Cheers

Author:  TinyWebGallery [ 16. Mar 2010, 09:13 ]
Post subject: 

You made a different one? I don't really know what you have done...

- Michael

Author:  simon_72 [ 16. Mar 2010, 09:24 ]
Post subject: 

I have an image.php with the following code that displays above the picture.

<?php
defined( '_VALID_TWG' ) or die( 'Direct Access to this location is not allowed.' );
//variables used
$folder = "$directory/";
$file = "$image";
?>
<a style="font-weight: bold;" target="_blank" href="<?php echo $folder;?><?php echo $file;?>">Download a copy of this image</a><img
style="border: 0px solid ; width: 25px; height: 25px;"
alt="Download Image Icon"
src="#removed_broken_link/buttons/downloads/download_image.gif">

It works fine normally, but if there is a space in the file name of the photo (which file minimizer automatically creates) then it puts a + in the link where the space should be rather than leaving it blank or replacing with %20, both which do work.

For example, this image:
#removed_broken_link/index.php ... zer%29.jpg

the image.php tries to open the link:
#removed_broken_link/pictures/ ... zer%29.jpg

which doesnt work. Where the + is needs to be either %20 or just a space, but i dont know how to change this since its not in my bit of code. If you manually change the above link, so:
#removed_broken_link/pictures/ ... zer%29.jpg

then it works fine?

Cheers

Author:  TinyWebGallery [ 16. Mar 2010, 12:32 ]
Post subject: 

use

first

urldecode
and then
rawurlencode

$file = rawurlencode(urldecode($image));

rawurlencode does convert the space to %20 as far as I remember.

I don't know why I have not used this here but there is for sure a reason I don't remember right now ;).

- Michael

PS: You should not use
$file = "$image";
this is very inefficient code.

Author:  simon_72 [ 16. Mar 2010, 20:45 ]
Post subject: 

Thanks for your help. It works now. Doesnt put %20 though, just leave a space :)

It probably is bad code. I dont know much PHP and it takes me ages to write it. What i put seemed to work so i left it!

Cheers once again
Simon

Author:  TinyWebGallery [ 16. Mar 2010, 20:56 ]
Post subject: 

Normally space should be encoded to %20 by this function. But if it works for you it is fine ;).

- Michael

Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/