Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用ftp_nb_上传到PHP中的FileZilla ftp服务器的文件已损坏_Php_Ftp - Fatal编程技术网

用ftp_nb_上传到PHP中的FileZilla ftp服务器的文件已损坏

用ftp_nb_上传到PHP中的FileZilla ftp服务器的文件已损坏,php,ftp,Php,Ftp,我正在尝试使用html表单上载文件。上传方法是通过FTP发送到FileZilla服务器。我已经成功上传了文件,但似乎只有它的文件扩展名和文件名才是被上传的。在windows资源管理器中查看传输的文件时,该文件始终损坏,并且不显示其文件大小。这是我的密码。请帮忙 include 'Connections/ftpgangconnect.php'; ini_set("upload_max_filesize", "250M"); ini_set("post_max_size", "250M"); if

我正在尝试使用html表单上载文件。上传方法是通过FTP发送到FileZilla服务器。我已经成功上传了文件,但似乎只有它的文件扩展名和文件名才是被上传的。在windows资源管理器中查看传输的文件时,该文件始终损坏,并且不显示其文件大小。这是我的密码。请帮忙

include 'Connections/ftpgangconnect.php';
ini_set("upload_max_filesize", "250M");
ini_set("post_max_size", "250M");

if (isset($_POST['upload'])) {
    $name = $_FILES['myfile'] ['name'];
    $size = $_FILES['myfile'] ['size'];
    $type = $_FILES['myfile'] ['type'];
    $temp = $_FILES['myfile'] ['tmp_name'];
    $error = $_FILES['myfile'] ['error'];
    $content = $_FILES['myfile']['content'];
    $temp = $_FILES['myfile'] ['tmp_name'];
    $name = $_FILES['myfile']['name'];
    $dest_file ="/".$name;

    // upload the file
    $upload = ftp_nb_put($ftp, $dest_file, $temp, FTP_BINARY);

    // check upload status
    if (!$upload) { 
        echo "FTP upload has failed!";
    } else {
        echo "Uploaded $name";
        ftp_close($ftp);
    }
}

请检查示例中的错误。您应该在循环中调用
ftp\u nb\u continue
,直到上传完成:

// upload the file
$upload = ftp_nb_put($ftp, $dest_file, $temp, FTP_BINARY);

while ($upload == FTP_MOREDATA)
{
   // Continue uploading...
   $upload = ftp_nb_continue($ftp);
}

尽管除非您需要在循环中执行任何其他操作,否则使用
ftp\u nb\u put
是毫无意义的。只需使用一个简单的:


请检查示例中的错误。您应该在循环中调用
ftp\u nb\u continue
,直到上传完成:

// upload the file
$upload = ftp_nb_put($ftp, $dest_file, $temp, FTP_BINARY);

while ($upload == FTP_MOREDATA)
{
   // Continue uploading...
   $upload = ftp_nb_continue($ftp);
}

尽管除非您需要在循环中执行任何其他操作,否则使用
ftp\u nb\u put
是毫无意义的。只需使用一个简单的: