[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

php problem with ftp_put

Posted on 2001-08-18
10
Medium Priority
?
361 Views
Last Modified: 2011-09-20
I have a problem with php4's ftp_put


I'm trying to send a file to a remote server, It opens the connection ok, creates an empty file then fails.

It gives an error message
Warning: ftp_put: PORT command successful. in liveStats.php3 on line 228

But it isn't successful - it just creates an empty file.

I can ftp to this site using other ftp software and have used this same bit of code to ftp to the site before.


Any ideas?


The code is

     // set up basic connection
     $conn_id = ftp_connect($address);

     // login with username and password
     $login_result = ftp_login($conn_id, $username, $pwd);

     // check connection
     if ((!$conn_id) || (!$login_result)) {
               $str.= "Ftp connection has failed!";
               $str.= "Attempted to connect to $ftp_server";
               die;
          } else {
               $str.= "Connected<br>";
          }

     // upload the file (dest,source)
     $upload = ftp_put($conn_id, $path.$source_file, $source_file, FTP_ASCII);

     // check upload status
     if (!$upload) {
               $str.= "Ftp upload has failed!";
          } else {
               $str.= "Uploaded ".$source_file." <br>\n";
          }

     // close the FTP stream
     ftp_quit($conn_id);

return $str;

0
Comment
Question by:Nick1181
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 15

Expert Comment

by:a.marsh
ID: 6400667
What kind of file are you uploading?

Have you tried using FTP_BINARY instead of FTP_ASCII?

:o)

Ant
0
 

Author Comment

by:Nick1181
ID: 6400685
Just a little text file. test.txt

I've tried using both FTP_BINARY and FTP_ASCII
0
 

Author Comment

by:Nick1181
ID: 6400718
It doesn't seem to want to send to another server I tried as well - probably doesn't want to send to any server
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 15

Accepted Solution

by:
a.marsh earned 400 total points
ID: 6400722
What operating system(s) are you using?

Ant
0
 

Author Comment

by:Nick1181
ID: 6400733
It doesn't seem to want to send to another server I tried as well - probably doesn't want to send to any server
0
 

Author Comment

by:Nick1181
ID: 6400749
Linux
Apache/1.3.14
PHP Version 4.0.5

http://www.the-afs.com/test.php3 for phpinfo()

0
 

Author Comment

by:Nick1181
ID: 6400844
Well I got it to go though I'm utterly mystefied as to why.

I just copied and pasted an example verbatim - then adapted it. As far as I can see the only difference is that

$upload = ftp_put($conn_id, $dest_file, $source_file, FTP_BINARY);

doesn't work and

$upload = ftp_put($conn_id, "$destination_file", "$source_file", FTP_BINARY);

does. ie: it seems to want quotes around the variable names - which is a whisker on the obscure side. Still, there you go


Thanks

Nick
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6400851
You say that this code has worked before...was that on a different machine and/or a different version of PHP?

There are bugs listed for these functions but they are generally when using Windows, not Linux.

Ant
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6400857
Okay - glad you sorted it.

However I'm not so pleased that you gave me a grade C.

If my help really wasn't worth more than that then I would rather that you deleted the question.

:o\

Ant
0
 

Author Comment

by:Nick1181
ID: 6401047
Sorry, As you can possibly spot from my duplicate reply I'm not exactly up to speed with this system.

I appreciate your help believe me. As it was the things you suggested weren't solutions so what do I do? Give you an A for something that wasn't a solution? Just deleting the question seemed a little rude - If giving a C is ruder then I guess I'll just delete in future.

Sorry again


Nick
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question