Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP Uploading

Status
Not open for further replies.

Quijian

ISP
Jul 9, 2004
32
US
I am trying to upload files onto my ftp server but I don't have a clue as to what is wrong with my code.

Code:
<?php
$path="C:\Documents and Settings\Blah Blah\My Documents\files\txt\LI.txt";
$remote="1.txt";
$ftp_server='ftp.example.com';//address for the ftp server
$ftp_user='screenname@example.com';
$ftp_pass='secret';
$connect_id=ftp_connect($ftp_server) or die("Couldn't connect to ftp server.");
if(ftp_login($connect_id, $ftp_user, $ftp_pass)){
	if(ftp_put($connect_id, $remote, $path, FTP_ASCII)){}
	else{
	echo "Upload not successful <br>";
	echo $path."<br>";
	echo $remote;
	}
}
else{
echo "Login not successful";
}	
?>
The path is exactly the way it should be and the remote path is fine too.

Thanks in all your help.
 
Two things jump out at me.

PHP uses backslashes as an escape character. So this line:

$path="C:\Documents and Settings\Blah Blah\My Documents\files\txt\LI.txt";

is being interpreted as "C:[escape D]ocuments and settings[escape B]......."

Since PHP doesn't interpolate string literals inside singlequotes, try the line as:

$path='C:\Documents and Settings\Blah Blah\My Documents\files\txt\LI.txt';

The other thing is that I don't know whether PHP will react well to the spaces in the path. You might have to use the short directory names (available doing "dir /x" at a command prompt).




Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top