Uploading problem - inserts // where / should be!

A

Anonymous

Guest
Hi everyone,

Im sure i have seen the solution to this before but i cant remember where!

Im setting up a file uploader, which all works well except the PHP script changes all the / to // which then gives an error becasue the filename cannot be found.

Anyone got any ideas on how to make it stay as / ?

Regards
 
Use the function str_replace()
here in the argument give the charecter to be replaced and the other argument to be replaced by what.
 
Use strip_slashes() - It removes all slashes added by PHP like on quotes and such.
 
you can use the block quotes to as php don't do anything with this string (no variable value substituion)
it will be much better if you post the code and test it on out machine for solution
 
Heres the code

Code:
<?php
if($file_name!="")
{
copy ("$file_name", "/home/httpd/vhosts/manchester-ra.org.uk/httpdocs/$file_name" )
        or die ("could not copy file") ;
}
?>

Regards[/code]
 
What exactly is the problem? Does it save the file as "//home//httpd//vhosts//manchester-ra.org.uk//httpdocs//"

The only time I have used copy I used the relative location of the file. Like if httpdocs was your document server root (where you put your index file. The copy could work like this...

Code:
copy("filetocopy.ext", "newcopiedfilename.ext");
 
yea it uploads it as "//home//httpd//vhosts//manchester-ra.org.uk//httpdocs//" and i cant get rid of the double /

Regards
 
Try this
Code:
copy ("$file_name", stripslashes("/home/httpd/vhosts/manchester-ra.org.uk/httpdocs/$file_name")) 
        or die ("could not copy file") ;
although, I am not too sure of it.
 
I've seen that happen on backslashes but not forward slashes
 
Back
Top