Page 1 of 1

uploading files with an apostrophe

Posted: Fri Feb 06, 2004 11:45 am
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

Posted: Fri Feb 06, 2004 11:59 am
by cgroup
You could change the apostrophe to a hyphen.

Code: Select all

$file_name = strtr($file_name, "'", "-");

Posted: Fri Feb 06, 2004 12:18 pm
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

Posted: Fri Feb 06, 2004 12:34 pm
by glennn3
$file_name = stripslashes($file_name);
copy (... );

that did the trick.

thanks