uploading files with an apostrophe

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
glennn3
Forum Commoner
Posts: 63
Joined: Sat Sep 20, 2003 8:43 pm

uploading files with an apostrophe

Post by glennn3 »

a simple upload script:

Code: Select all

...
@copy ($file, "$absolute_path/$file_name") or $endresult = "<font size="2">Couldn't Copy File To Server</font>";
but persons are using apostrophes, so i tried

Code: Select all

$file_name = strtr($file_name, "'", "");
@copy ($file, "$absolute_path/$file_name") or $endresult = "<font size="2">Couldn't Copy File To Server</font>";
but it did nothing.

the problem is that magic_quotes is adding the slash to the file in the directory and now i can't delete it or open it - i'm a newbie and don't know exactly how this obviously common problem is tackled...

help?

thanks
cgroup
Forum Newbie
Posts: 13
Joined: Tue Jun 03, 2003 11:51 pm
Location: PA

Post by cgroup »

You could change the apostrophe to a hyphen.

Code: Select all

$file_name = strtr($file_name, "'", "-");
glennn3
Forum Commoner
Posts: 63
Joined: Sat Sep 20, 2003 8:43 pm

Post by glennn3 »

this worked but still added a slash - document's.doc becomes document\-s.doc - probably i need to get the ' removed first off... ?

g
glennn3
Forum Commoner
Posts: 63
Joined: Sat Sep 20, 2003 8:43 pm

Post by glennn3 »

$file_name = stripslashes($file_name);
copy (... );

that did the trick.

thanks
Post Reply