Uploading problem - inserts // where / should be!

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

fspilot
New php-forum User
New php-forum User
Posts: 26
Joined: Fri Jun 27, 2003 11:51 am
Location: Bath UK
Contact:

Uploading problem - inserts // where / should be!

Postby fspilot » Tue Sep 02, 2003 4:09 am

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

sleepingdanny
New php-forum User
New php-forum User
Posts: 13
Joined: Mon Mar 17, 2003 6:38 am

Postby sleepingdanny » Tue Sep 02, 2003 7:33 am

Post your code please

User avatar
ruturajv
php-forum Super User
php-forum Super User
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India
Contact:

str_replace

Postby ruturajv » Tue Sep 02, 2003 8:40 pm

Use the function str_replace()
here in the argument give the charecter to be replaced and the other argument to be replaced by what.

Joel
New php-forum User
New php-forum User
Posts: 193
Joined: Sat Mar 29, 2003 11:57 pm
Location: Auckland, New Zealand
Contact:

Postby Joel » Wed Sep 03, 2003 12:26 am

Use strip_slashes() - It removes all slashes added by PHP like on quotes and such.

sigix
php-forum Active User
php-forum Active User
Posts: 364
Joined: Mon Jul 14, 2003 9:39 pm
Location: /Earth/Xion

Postby sigix » Wed Sep 03, 2003 1:23 am

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

fspilot
New php-forum User
New php-forum User
Posts: 26
Joined: Fri Jun 27, 2003 11:51 am
Location: Bath UK
Contact:

Postby fspilot » Wed Sep 03, 2003 8:45 am

Heres the code

Code: Select all

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

Joel
New php-forum User
New php-forum User
Posts: 193
Joined: Sat Mar 29, 2003 11:57 pm
Location: Auckland, New Zealand
Contact:

Postby Joel » Wed Sep 03, 2003 9:09 pm

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: Select all

copy("filetocopy.ext", "newcopiedfilename.ext");

fspilot
New php-forum User
New php-forum User
Posts: 26
Joined: Fri Jun 27, 2003 11:51 am
Location: Bath UK
Contact:

Postby fspilot » Thu Sep 04, 2003 10:07 am

yea it uploads it as "//home//httpd//vhosts//manchester-ra.org.uk//httpdocs//" and i cant get rid of the double /

Regards

Joel
New php-forum User
New php-forum User
Posts: 193
Joined: Sat Mar 29, 2003 11:57 pm
Location: Auckland, New Zealand
Contact:

Postby Joel » Thu Sep 04, 2003 11:45 pm

Try this

Code: Select all

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.

User avatar
Redcircle
Moderator
Moderator
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA
Contact:

Postby Redcircle » Fri Sep 05, 2003 3:43 pm

I've seen that happen on backslashes but not forward slashes


Return to “PHP coding => General”

Who is online

Users browsing this forum: Google [Bot] and 1 guest