badwolfff
asked on
How do I urlencode filenames in an array inside a PHP file?
I have a joomla plugin file called sige.php attached here where around line 838 you will find this code:
$testUrl = '<a href="mailto:?subject =Zuenelli% 20propone& body='.$mo sConfig_li ve_site.'/ plugins/co ntent/sige /plugin_si ge/socials hare.php?i mg='.rawur lencode($m osConfig_l ive_site.$ rootfolder .$_images_ dir_.'/Mid size/'.$im ages[$a][' filename'] ).'&na me='.rawur lencode($t itle_iptc) .'&cap tion='.raw urlencode( $caption_i ptc).'&quo t;';
//send link via email
$html .= $testUrl.' title="invia link via email" ><img src="'.$mosConfig_liv e_site.'/p lugins/con tent/sige/ plugin_sig e/email.pn g" /></a>';
The jpg files that my client uploads into the folder /Midsize/ mentioned above sometimes have spaces in their names and sometimes they also contain latin characters/accents and this cannot be avoided. The code above works fine as the rawurlencode sorts all other parts of the URL that is generated on the fly in $testURL except for the current file's name which is retreived from the array filename.
So unfortunately when I run this code and click on the email button I get a url that looks like this:
http://localhost:8888/zuenelli/plugins/content/sige/plugin_sige/socialshare.php?img=http://localhost:8888/zuenelli/images/sda/galleries/giorno_librerietavoli/Midsize/Feg - 1 - (2).jpg
This does not work due to the spaces - when this mailto code is launched and the outlook or mail window opens on pc or mac only the first part is clickable and all the parts after the space are just simple text).
Also the last part is being ignored:
&name='.rawurlencode($ title_iptc ).'&ca ption='.ra wurlencode ($caption_ iptc)
The real link should be something link this:
http://localhost:8888/zuenelli/plugins/content/sige/plugin_sige/socialshare.php?img=http%3A%2F%2Flocalhost%3A8888%2Fzuenelli%2Fimages%2Fsda%2Fgalleries%2Fgiorno_librerietavoli%2FMidsize%2FFeg%20-%201%20-%20%282%29.jpg&name=Feg%20-%201%20-%20%282%29
What am I doing wrong?
thanks in advance
sige.php
$testUrl = '<a href="mailto:?subject
//send link via email
$html .= $testUrl.' title="invia link via email" ><img src="'.$mosConfig_liv
The jpg files that my client uploads into the folder /Midsize/ mentioned above sometimes have spaces in their names and sometimes they also contain latin characters/accents and this cannot be avoided. The code above works fine as the rawurlencode sorts all other parts of the URL that is generated on the fly in $testURL except for the current file's name which is retreived from the array filename.
So unfortunately when I run this code and click on the email button I get a url that looks like this:
http://localhost:8888/zuenelli/plugins/content/sige/plugin_sige/socialshare.php?img=http://localhost:8888/zuenelli/images/sda/galleries/giorno_librerietavoli/Midsize/Feg - 1 - (2).jpg
This does not work due to the spaces - when this mailto code is launched and the outlook or mail window opens on pc or mac only the first part is clickable and all the parts after the space are just simple text).
Also the last part is being ignored:
&name='.rawurlencode($
The real link should be something link this:
http://localhost:8888/zuenelli/plugins/content/sige/plugin_sige/socialshare.php?img=http%3A%2F%2Flocalhost%3A8888%2Fzuenelli%2Fimages%2Fsda%2Fgalleries%2Fgiorno_librerietavoli%2FMidsize%2FFeg%20-%201%20-%20%282%29.jpg&name=Feg%20-%201%20-%20%282%29
What am I doing wrong?
thanks in advance
sige.php
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.