php - ftp_put sends incomplete file

454

i have to put an xml file to a remote server, using php.

my file is created by a php script (and everything is ok), then i upload it to another server.
but when it goes there, the file is incomplete! lasts 10 lines are stripped out.

any help?

PHP CODE

function upload(){  
    $ftp = ftp_connect('ftp.myhost.com');  
    $rc  = ftp_login($ftp, 'myuser', 'mypwd');  
    $rc  = ftp_pasv ($ftp, FALSE);  
    $rc  = ftp_chdir($ftp, $folder);  
    $rc  = ftp_put  ($ftp, 'myfile.xml', 'myfile.xml', FTP_ASCII);  
    ftp_close($ftp);  
}
140

Answer

Solution:

Have you tried using 'FTP_BINARY' instead of 'FTP_ASCII'?

Also, I don't think its what is causing your problem but where does the $folder variable get populated in your code?

189

Answer

Solution:

HI,

User FTP_BINARY instead of FTP_ASCII check for the filesize also, may be possible that your server does not allow heavy files

People are also looking for solutions to the problem: regex - i want to build regular expression to extract substring from string in php

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.