Uploading problem - inserts // where / should be!



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 / ?

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

copy ("$file_name", "/home/httpd/vhosts/manchester-ra.org.uk/httpdocs/$file_name" )
        or die ("could not copy file") ;

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...

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 /

Try this
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