Jump to content

[SOLVED] FTP_PUT uploading empty file


etm124

Recommended Posts

i'm connecting and logging into a ftp server fine.

 

but when i try to put a file onto the server, it is an empty file. below is a snippet of my code.

 

Here is the print out of my debug messages:

 

connected to ftpupload.clickatell.com, for user 3097489. Login variable: 1

CONN_ID: Resource id #7

FILENAME: 7890_20080609095235_SMS.txt

PACKAGE: /usr/src/rapid/uploads/7890/sms/packages/7890_20080609095235_SMS.txt

bool(false)

FTP upload has failed!

 

 

Am I using FTP_PUT correctly?

 

$ftp_server = "ftpupload.clickatell.com";

$ftp_user_name = $api;
$ftp_pw = $pw;

$conn_id = ftp_connect($ftp_server) or die ("cannot connect to ftp server");

$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_pw) or die("no ftp $conn_id $ftp_user_name $ftp_pw $ftp_server");


if($login_result){
echo "connected to $ftp_server, for user $ftp_user_name";
}

$sms_package_filename = $sms_package_id . ".txt";
$upload = ftp_put($conn_id, $sms_package_filename, $sms_package, FTP_ASCII);
echo "<br>CONN_ID: $conn_id <br>";
echo "FILENAME: $sms_package_filename <br>";
echo "PACKAGE: $sms_package <br>";
echo var_dump($upload) ." <br>";


if ($upload===false) {  // check upload status
         echo "<h2>FTP upload  has failed!</h2> <br />";
      } else {
         echo "Uploading Complete!<br /><br />";
      }

 

Apache also owns all my files/dirs

 

[root@srv1 html]# cd /usr/src/rapid/uploads/7890/
[root@srv1 7890]# ll
total 28
drwxr-xr-x 2 apache apache 4096 May 30 23:50 datafiles
drwxr-xr-x 3 apache apache 4096 Jun  3 00:20 emails
drwxr-xr-x 2 apache apache 4096 Aug 15  2006 greetings
drwxr-xr-x 2 apache apache 4096 Apr 23 09:43 messages
drwxr-xr-x 2 apache apache 4096 Jun  3 00:16 phonelists
drwxr-xr-x 4 apache apache 4096 Jun  3 14:44 sms
drwxr-xr-x 2 apache apache 4096 May 19 21:41 sqlfiles
[root@srv1 7890]# cd sms/
[root@srv1 sms]# ll
total 8
drwxr-xr-x 2 apache apache 4096 Jun  3 15:52 messages
drwxr-xr-x 2 apache apache 4096 Jun  9 09:28 packages
[root@srv1 sms]# cd packages/
[root@srv1 packages]# ll
total 104
-rw-r--r-- 1 apache apache 69 Jun  3 15:53 7890_20080603155308_SMS.txt
-rw-r--r-- 1 apache apache 69 Jun  3 15:53 7890_20080603155356_SMS.txt
-rw-r--r-- 1 apache apache 69 Jun  3 15:55 7890_20080603155544_SMS.txt
-rw-r--r-- 1 apache apache 69 Jun  3 16:02 7890_20080603160254_SMS.txt
-rw-r--r-- 1 apache apache 69 Jun  3 16:03 7890_20080603160342_SMS.txt
-rw-r--r-- 1 apache apache 69 Jun  3 16:04 7890_20080603160419_SMS.txt
-rw-r--r-- 1 apache apache 69 Jun  3 16:04 7890_20080603160439_SMS.txt
-rw-r--r-- 1 apache apache 69 Jun  3 16:05 7890_20080603160521_SMS.txt
-rw-r--r-- 1 apache apache 69 Jun  3 16:10 7890_20080603161042_SMS.txt
-rw-r--r-- 1 apache apache 69 Jun  3 16:11 7890_20080603161123_SMS.txt
-rw-r--r-- 1 apache apache 69 Jun  3 16:45 7890_20080603164558_SMS.txt
-rw-r--r-- 1 apache apache 69 Jun  4 08:41 7890_20080604084158_SMS.txt
-rw-r--r-- 1 apache apache 69 Jun  4 08:50 7890_20080604085022_SMS.txt
-rw-r--r-- 1 apache apache 69 Jun  4 08:53 7890_20080604085342_SMS.txt
-rw-r--r-- 1 apache apache 69 Jun  4 08:53 7890_20080604085352_SMS.txt
-rw-r--r-- 1 apache apache 69 Jun  4 08:54 7890_20080604085408_SMS.txt
-rw-r--r-- 1 apache apache 69 Jun  4 08:58 7890_20080604085806_SMS.txt
-rw-r--r-- 1 apache apache 69 Jun  4 09:06 7890_20080604090640_SMS.txt
-rw-r--r-- 1 apache apache 69 Jun  4 09:17 7890_20080604091737_SMS.txt
-rw-r--r-- 1 apache apache 69 Jun  4 10:51 7890_20080604105102_SMS.txt
-rw-r--r-- 1 apache apache 69 Jun  4 10:59 7890_20080604105922_SMS.txt
-rw-r--r-- 1 apache apache 69 Jun  4 11:12 7890_20080604111250_SMS.txt
-rw-r--r-- 1 apache apache 69 Jun  9 09:12 7890_20080609091253_SMS.txt
-rw-r--r-- 1 apache apache 69 Jun  9 09:23 7890_20080609092306_SMS.txt
-rw-r--r-- 1 apache apache 69 Jun  9 09:27 7890_20080609092700_SMS.txt
-rw-r--r-- 1 apache apache 69 Jun  9 09:28 7890_20080609092841_SMS.txt

 

Thanks for any help you might be able to give.

Link to comment
Share on other sites

Hi MadTechie,

 

Thanks for the response, but i think my order is correct:

 

from php.net:

bool ftp_put  ( resource $ftp_stream  , string $remote_file  , string $local_file  , int $mode  [, int $startpos  ] )

 

my $sms_package does exist, my file location is echoed out:

PACKAGE: /usr/src/rapid/uploads/7890/sms/packages/7890_20080609095235_SMS.text

 

 

[steckbeck@srv1 html]$ cat /usr/src/rapid/uploads/7890/sms/packages/7890_20080609095235_SMS.txt
api_id:3097489
user:etm124
password:XXX
to:XXX
text:test

 

password and my cell phone number omitted :P

 

Link to comment
Share on other sites

Here is a warning i get in my ssl_error log:

 

[Mon Jun 09 11:25:42 2008] [error] [client 216.37.164.100] PHP Warning:  ftp_put() [<a href='function.ftp-put'>function.ftp-put</a>]: PORT command successful in /var/www/html/sms_alert.php on line 55, referer: https://srv1.publicnotify.com/sms_alert.php

Link to comment
Share on other sites

echo "FILENAME: $sms_package_filename <br>";
echo "PACKAGE: $sms_package <br>";

FILENAME: 7890_20080609095235_SMS.txt

PACKAGE: /usr/src/rapid/uploads/7890/sms/packages/7890_20080609095235_SMS.txt

 

so

$upload = ftp_put($conn_id, $sms_package_filename, $sms_package, FTP_ASCII);

 

parses to

$upload = ftp_put($conn_id, '7890_20080609095235_SMS.txt', '/usr/src/rapid/uploads/7890/sms/packages/7890_20080609095235_SMS.txt', FTP_ASCII);

 

Now

'7890_20080609095235_SMS.txt' doesn't contain the FTP Path

 

it should be like this

<?php
$site_root = '/path to files to be uploaded/';
$ftp_root = '/usr/src/rapid/uploads/7890/sms/packages/';
ftp_put($conn_id, $ftp_root . $sms_package_filename, $site_root . $sms_package_filename, FTP_ASCII);

?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.