Marius
Marius

Reputation: 545

How to make SharePoint accept attachments with special characters in the file name?

I noticed that every time I try to attach a file to a SharePoint list, if the file name contains any special characters (#, &, @, ...) it will not go through. Will not be attached and will cause an error. Is there any way around that? Thanks,

Upvotes: 2

Views: 7476

Answers (3)

Meredith
Meredith

Reputation: 11

I was able to create a javascript input validation on the client side that would check for special characters and prompt the user to rename the filename before submitting the item. This works on MOSS 2007 and WSS.

See this post: http://sharepointchic.blogspot.com/2010/12/input-validation-for-file-attachment.html

Upvotes: 1

ArjanP
ArjanP

Reputation: 2172

Rename your files first? These characters are not banned because SharePoint is fussy but because they mean something in the url adressible world; it makes sense not to use ? and / etc. in your filenames because they are reserved characters in urls.

Upvotes: 2

x0n
x0n

Reputation: 52430

You can create an "event receiver" (see SPItemEventReceiver class on msdn) that will watch for the ItemAttaching event which occurs before the item is attached. This will let you replace the invalid characters with legal replacements.

Bear in mind that if you replace all invalid chars with the same one - "_" for example - the onus is on you to avoid name collisions.

-Oisin

Upvotes: 2

Related Questions