繁体   English   中英

无法使用php将文件上传到ftp服务器

[英]Unable to upload file to ftp server using php

我正在尝试使用php将文件上传到FTP服务器,但没有被上传。

码:

   $response =<<<RESPONSE
    <cdm:Response>
    <cdm:header exportTime="{$export_time}" baseVersion="{$baseline_snapshot_id}" version="{$this->snapshot_id}">
            <cdm:countryCode>{$this->domain}</cdm:countryCode>
            <cdm:description>{$description}</cdm:description>
            <cdm:environment>{$destination}</cdm:environment>
            <cdm:name>{$name}</cdm:name>
    </cdm:header>
    <cdm:Status>{$this->status}</cdm:Status>
    </cdm:Response>
    RESPONSE;

   $handler = fopen($log_file_name, 'w');
   fwrite($handler, $response);
   fclose($handler);

   $server = "adoshi.dev.com";
   $ftp_user_name = "adoshi";
   $ftp_user_pass = "*******";
   #$source = $handler;
   $mode = "FTP_ASCII";
   $dest = "/home/adoshi/ftp_folder";
   $connection = ftp_connect($server);
   $login = ftp_login($connection, $ftp_user_name, $ftp_user_pass);
   if (!$connection || !$login) { die('Connection attempt failed!'); }
   $upload = ftp_nb_put($connection, $dest, $handler, $mode);
   if (!$upload) { echo 'FTP upload failed!'; }
   ftp_close($connection);

我提供了所有正确的登录凭据,因此仍然想知道为什么它不使用php上传到远程服务器。

任何指导将不胜感激。

您不需要创建文件处理程序来上传它们,您只需要该文件的路径和文件名即可

$destFile= "test.htm";
$lokal_file = "test.htm";
$upload = ftp_put ($connection_id, $destFile, $lokal_file, FTP_ASCII);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM