Php photo gallery TWG | JFUploader | TWG Flash upload | WFU | Forum

Get help for TinyWebGallery, the best image gallery. The forum is also home for the Joomla JFUploader, TWG Flash Uploader and the Wordpress flash uploader.
It is currently 30. Jun 2024, 14:50

This forum is readonly now. Please use the new forum if you don't find the answer to your question here. The new forum is at https://www.tinywebgallery.com/blog/forum/


All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: image.php
PostPosted: 16. Mar 2010, 09:08 
Offline
User avatar

Joined: 20. May 2009, 11:46
Posts: 38
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

_________________
Simon Tickle
www.anyhowracing.co.uk


Top
 Profile  
 
 Post subject:
PostPosted: 16. Mar 2010, 09:13 
Offline
Site Admin
User avatar

Joined: 1. Aug 2005, 12:53
Posts: 11232
You made a different one? I don't really know what you have done...

- Michael


Top
 Profile  
 
 Post subject:
PostPosted: 16. Mar 2010, 09:24 
Offline
User avatar

Joined: 20. May 2009, 11:46
Posts: 38
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

_________________
Simon Tickle
www.anyhowracing.co.uk


Top
 Profile  
 
 Post subject:
PostPosted: 16. Mar 2010, 12:32 
Offline
Site Admin
User avatar

Joined: 1. Aug 2005, 12:53
Posts: 11232
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.


Top
 Profile  
 
 Post subject:
PostPosted: 16. Mar 2010, 20:45 
Offline
User avatar

Joined: 20. May 2009, 11:46
Posts: 38
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

_________________
Simon Tickle
www.anyhowracing.co.uk


Top
 Profile  
 
 Post subject:
PostPosted: 16. Mar 2010, 20:56 
Offline
Site Admin
User avatar

Joined: 1. Aug 2005, 12:53
Posts: 11232
Normally space should be encoded to %20 by this function. But if it works for you it is fine ;).

- Michael


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
powered by phpbb | Datenschutz/ Privacy policy