Page 1 of 1

[SOLVED] upload problems

Posted: Sat Jan 08, 2005 6:40 pm
by shiznatix
ok i started sayin somtin earlier in another post but i figured this will be easier for all parties. i have a file uploading thing but whenever i upload a file that has a ' character it turns it into a \ character. iv tried all of these and nothing has worked

Code: Select all

<?php
$file = ($_FILES['thefile']['name']);
$file = str_replace("'", "", $file);
$file = stripslashes($file);
?>

Code: Select all

<?php
stripslashes($_FILES['thefile']['name']);
$_FILES['thefile']['name'] = str_replace("'", "", $_FILES['thefile']['name']);
?>

Code: Select all

<?php
stripslashes($_FILES['thefile']['tmp_name']);
$_FILES['thefile']['tmp_name'] = str_replace("'", "", $_FILES['thefile']['tmp_name']);
?>
but nothing takes the \ mark out of the file name. how do i do this?
p.s im sure its clear that i have no idea what im doing when it comes to file upload handling :?

Posted: Sat Jan 08, 2005 6:48 pm
by markl999
whenever i upload a file that has a ' character it turns it into a \ character
Can you clarify that? Does a ' become a \ or a '' ?

Posted: Sat Jan 08, 2005 6:56 pm
by shiznatix
it becomes a ''

Posted: Sat Jan 08, 2005 7:16 pm
by markl999
As a test what does the following output?

Code: Select all

echo $_FILES['thefile']['name'].'<br />';
echo str_replace('\\\'', '', $_FILES['thefile']['name']).'<br />';
echo stripslashes($_FILES['thefile']['name']).'<br />';

Posted: Sat Jan 08, 2005 8:59 pm
by shiznatix
when you echo it the output is correct but whenever you take out echo the ' character is still ''

Posted: Sat Jan 08, 2005 9:01 pm
by markl999
Then don't echo ;)
The echo's were just a test, if you do:
$file = str_replace('\'', '', $_FILES['thefile']['name']); then $file should be ok; echo $file to test.

Posted: Sat Jan 08, 2005 9:07 pm
by shiznatix

Code: Select all

<?php
str_replace('\'', '', $_FILES['thefile']['name']);
stripslashes($_FILES['thefile']['name']);
if(is_uploaded_file($_FILES['thefile']['tmp_name'])) {
move_uploaded_file($_FILES['thefile']['tmp_name'],$uploadto.'/'.$_FILES['thefile']['name'])
?>
is what im doing and its still messing up, sorry i didnt make that very clear in my last reply

Posted: Sat Jan 08, 2005 9:09 pm
by markl999
Try:

Code: Select all

$_FILES['thefile']['name'] = stripslashes($_FILES['thefile']['name']);

Posted: Sat Jan 08, 2005 9:48 pm
by shiznatix
wow...that worked. thanks like 100 million.