Solved

File name of email attachment

Posted on 2016-09-29
4
30 Views
Last Modified: 2016-09-29
I build the filename of an email attachment based on a "property description".

In a particular case, the property description is #68 Residence.

That is passed as a $_GET variable to the emailing routine; I'm guessing that either # is not allowed in a file name (or more likely) # does not get properly passed in the query string.

Should I just replace # with # in the query string? Not sure if that stuff in a file name would work.

Or maybe better yet, I could probably just throw away the #, not needed in this case, but there are probably other special characters.

Suggested solution?
0
Comment
Question by:Richard Korts
4 Comments
 
LVL 42

Assisted Solution

by:zephyr_hex (Megan)
zephyr_hex (Megan) earned 125 total points
ID: 41822397
If you're adding the $_GET parameter using PHP, you should use urlencode() to properly encode your url.

If you're using something other than PHP, please let us know how that parameter is added to the url.
0
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 125 total points
ID: 41822398
Get rid of any version of '#', it is not a legal part of the file name in a query string.  It is used to locate a named or id'd anchor on a page.  In addition, any spaces will be changed to %20.  It is best not to have spaces in the first place.
0
 
LVL 34

Accepted Solution

by:
gr8gonzo earned 250 total points
ID: 41822526
When I deal with filenames, I usually replace any non-valid characters with underscores:

$file = "My Residence @ #68 main st.";
$file  = preg_replace("/[^a-zA-Z0-9]/","_",$file);
// $file is now "My_Residence___68_main_st_";

You can additionally trim the _ down a little bit (consolidate multiple ___ to just one _, etc), but that should ensure that all filenames will be valid.
0
 

Author Closing Comment

by:Richard Korts
ID: 41822615
Thank you, I got all of it I & understand.

Richard
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Why my select dropdown does not work? 8 41
HTML &#0153 2 17
Javascript_Set_dropdown_value 7 33
Which non-HTML GUI front end to use with Java? 3 22
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question