The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> System Administration
> FTP Help
|
ftp_put error - need help
Discuss ftp_put error - need help in the FTP Help forum on Dev Shed. ftp_put error - need help FTP Help forum discussing FTP practices, tips and solutions for problems with FTP on multiple platforms. File Transfer Protocol (FTP) was designed specifically for transferring files from one machine to another.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

June 12th, 2002, 08:20 AM
|
|
Junior Member
|
|
Join Date: Jun 2002
Posts: 5
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
ftp_put error - need help
<?php
$server="ftp.myserver.com";
$user="myuser";
$pass="mypass";
// Connect & login to FTP server
$ftp=ftp_connect($server) or die ("Problem with FTP server !");
$conn=ftp_login($ftp,$user,$pass) or die ("Problem logining on to FTP server");
$dir=ftp_pwd($ftp); // Stores current directory as $dir
$file=$dir."/uploaded/datafile.txt"; // name of file we want to upload
$localfile = "C:\testfile.txt";
$upload=ftp_put($ftp,$file,$localfile,ftp_binary) or die ("Problem with upload");
?>
RESULT : Warning: error opening
C:\datafile.txt in ......script name
Can anyone help ?
If tried replacing C:\ with C:/ and C:// and lots of other combinations !
Please Help
v10
|

June 12th, 2002, 08:42 AM
|
 |
/(bb|[^b]{2})/
|
|
Join Date: Nov 2001
Location: Somewhere in the great unknown
|
|
|
What OS, I know you are running a windoze machine, but is it NT,2000,XP? If so, does the web server have permissions to read the directory you are trying to access?
Try moving the file you are trying to upload into the same directory that the script is located and see if that works.
You might also want to ftp_chdir to the exact directory you are wanting to upload to.
Last edited by Onslaught : June 12th, 2002 at 08:45 AM.
|

June 12th, 2002, 10:01 AM
|
 |
Mobbing Gangster
|
|
Join Date: Sep 2001
Location: "Best City" 2002 and 2003- Melbourne, Australia
|
|
|
Ok, first of all it should be $localfille="c:\\testfile.txt"; or $localfile='c:\testfile.txt'; and then, why do you upload .txt file in binary? Should be FTP_ASCII (note the capital letters, same with ftp_binary, should be capital)
__________________
And you know I mean that.
|

June 12th, 2002, 10:25 AM
|
|
Junior Member
|
|
Join Date: Jun 2002
Posts: 5
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
ahhhhh, still not working
Ok, My Pc is running Win98SE and the server is UNIX.
The script now reads as follows :
<?php
$server="ftp.server.com";
$user="user";
$pass="pass";
// Connect & login to FTP server
$ftp=ftp_connect($server) or die ("Problem with FTP server !");
$conn=ftp_login($ftp,$user,$pass) or die ("Problem logining on to FTP server");
$dir=ftp_pwd($ftp); // Stores current directory as $dir
$file=$dir."/uploaded/datafile.txt"; // name of file we want to upload
$localfile = 'C:\testfile.txt';
$upload=ftp_put($ftp,$file,$localfile,FTP_ASCII) or die ("Problem with upload");
?>
Still no Joy, Please help.... this is bugging me .....!
Thanks for the help,
V10
|

June 12th, 2002, 10:31 AM
|
 |
Mobbing Gangster
|
|
Join Date: Sep 2001
Location: "Best City" 2002 and 2003- Melbourne, Australia
|
|
|
"no joy" as in....
|

June 12th, 2002, 10:40 AM
|
|
Junior Member
|
|
Join Date: Jun 2002
Posts: 5
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
No joy as in it's still not working.
Can you help Mr. Capone ?
I read somewhere else that ftp_put can only move files from one server to another, but I don't believe that, as that wouldn't be the normal use of ftp ?
I've also seen this type of problem posted all over the place with similar type replies and no solution but I'm not a quitter.
Surely this is possible, and someone out there knows a solution.
It could be you.
C'mon, put your thinking cap on
V10
|

June 12th, 2002, 10:51 AM
|
 |
Mobbing Gangster
|
|
Join Date: Sep 2001
Location: "Best City" 2002 and 2003- Melbourne, Australia
|
|
|
>>I read somewhere else that ftp_put can only move files from one server
>> to another, but I don't believe that, as that wouldn't be the normal use
>> of ftp ?
BS. What you've just describes is called fxp'ing, and it is widely popular in..uhm... not so legitimate purposes.
What I meant is, what erros do you get? Try echoing each var before ftp_put and see if it says what you want.
|

June 12th, 2002, 11:05 AM
|
|
Junior Member
|
|
Join Date: Jun 2002
Posts: 5
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Ok it now reads :
<?php
$server="ftp.server.com";
$user="user";
$pass="name";
// Connect & login to FTP server
$ftp=ftp_connect($server) or die ("Problem with FTP server !");
$conn=ftp_login($ftp,$user,$pass) or die ("Problem logining on to FTP server");
$dir=ftp_pwd($ftp); // Stores current directory as $dir
$file=$dir."/ftp/datafile.txt"; // name of file we want to upload
$localfile = 'C:\testfile.txt';
echo "Connected to : $server as user : $user on Directory : $dir <br>";
echo "The plan is to upload this file : $localfile to this directory : $file on the server <br>";
$upload=ftp_put($ftp,$file,$localfile,FTP_ASCII) or die ("Problem with upload");
?>
Result :
Connected to : ftp.server.com as user : user on Directory : /
The plan is to upload this file : C:\testfile.txt to this directory : /ftp/datafile.txt on the server
Warning: error opening C:\testfile.txt in /home/ftp/ftpscript.php on line 19
Problem with upload
Appreciate the help al, what do you think ?
V10
|

June 12th, 2002, 11:08 AM
|
 |
Mobbing Gangster
|
|
Join Date: Sep 2001
Location: "Best City" 2002 and 2003- Melbourne, Australia
|
|
What do I think? I think this is probably the longest thread about the dummest mistake  You're on unix host, and you're trying to open file c:\testfile.txt on server's hdd. Sure enough, it gives errors, and you know why? There is no c:\testfile.txt, heck there is no c:\ there is / So you'll have to edit your path accordinally.
|

June 12th, 2002, 11:18 AM
|
|
Junior Member
|
|
Join Date: Jun 2002
Posts: 5
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
huh ?
hmmm, I'm trying to upload from the users hdd to my unix server.
The file C:\testfile.txt is on the same pc as the browser right ?
I know there is no C drive on my server but the file isn't on my server, it's on a local pc with a browser running win98 that has a C drive.
Am I seriously not with it today or what ?
What way should I address the C drive of the users pc or can I ?
Thanks for bearing with me
V10
|

June 12th, 2002, 11:45 AM
|
 |
Mobbing Gangster
|
|
Join Date: Sep 2001
Location: "Best City" 2002 and 2003- Melbourne, Australia
|
|
|
PHP is server side langauge and therefore every file you request comes from server.
>>What way should I address the C drive of the users pc or can I?
You simply can't. At least not directly. What you could do though is to first make users upload file to server and then put it on ftp.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|