Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Uploading problem - inserts // where / should be!

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

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
fspilot
New php-forum User
New php-forum User
 
Posts: 26
Joined: Fri Jun 27, 2003 11:51 am
Location: Bath UK

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

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

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.
User avatar
ruturajv
php-forum Super User
php-forum Super User
 
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India

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

Use strip_slashes() - It removes all slashes added by PHP like on quotes and such.
Joel
New php-forum User
New php-forum User
 
Posts: 193
Joined: Sat Mar 29, 2003 11:57 pm
Location: Auckland, New Zealand

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
sigix
php-forum Active User
php-forum Active User
 
Posts: 364
Joined: Mon Jul 14, 2003 9:39 pm
Location: /Earth/Xion

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]
fspilot
New php-forum User
New php-forum User
 
Posts: 26
Joined: Fri Jun 27, 2003 11:51 am
Location: Bath UK

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");
Joel
New php-forum User
New php-forum User
 
Posts: 193
Joined: Sat Mar 29, 2003 11:57 pm
Location: Auckland, New Zealand

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
fspilot
New php-forum User
New php-forum User
 
Posts: 26
Joined: Fri Jun 27, 2003 11:51 am
Location: Bath UK

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.
Joel
New php-forum User
New php-forum User
 
Posts: 193
Joined: Sat Mar 29, 2003 11:57 pm
Location: Auckland, New Zealand

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

I've seen that happen on backslashes but not forward slashes
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA


Return to PHP coding => General

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Yahoo [Bot] and 4 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.