Solved

File name of email attachment

Posted on 2016-09-29
4
23 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
zephyr_hex 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 82

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now