Hướng dẫn php ftp download file to browser - php ftp tải tệp xuống trình duyệt

Tôi sử dụng mã này để tải xuống một tệp vào bộ nhớ từ FTP:

public static function getFtpFileContents($conn_id , $file)
{
    ob_start();
    $result = ftp_get($conn_id, "php://output", $file, FTP_BINARY);
    $data = ob_get_contents();
    ob_end_clean();
    if ($resul)
        return $data;
    return null;
}

Làm thế nào tôi có thể làm trực tiếp gửi tệp cho người dùng (trình duyệt) mà không lưu vào đĩa và không chuyển hướng đến máy chủ FTP?

Hướng dẫn php ftp download file to browser - php ftp tải tệp xuống trình duyệt

Hỏi ngày 11 tháng 11 năm 2017 lúc 17:12Nov 11, 2017 at 17:12

0

Chỉ cần loại bỏ bộ đệm đầu ra (ob_start() và các bộ khác).

Chỉ sử dụng cái này:

ftp_get($conn_id, "php://output", $file, FTP_BINARY);

Mặc dù nếu bạn muốn thêm tiêu đề Content-Length, bạn phải truy vấn kích thước tệp trước bằng cách sử dụng ftp_size:

$conn_id = ftp_connect("ftp.example.com");
ftp_login($conn_id, "username", "password");
ftp_pasv($conn_id, true);

$file_path = "remote/path/file.zip";
$size = ftp_size($conn_id, $file_path);

header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=" . basename($file_path));
header("Content-Length: $size"); 

ftp_get($conn_id, "php://output", $file_path, FTP_BINARY);

(Thêm xử lý lỗi)


Để biết thêm nền tảng rộng hơn, xem: Danh sách và tải xuống tệp đã nhấp từ FTP
List and download clicked file from FTP

Đã trả lời ngày 11 tháng 11 năm 2017 lúc 17:23Nov 11, 2017 at 17:23

Martin Prikrylmartin PrikrylMartin Prikryl

Phim thương hiệu vàng 174K5151 gold badges430 silver badges889 bronze badges

0

public static function getFtpFileContentsWithSize($conn_id , $file)
{
    ob_start();
    $result = ftp_get($conn_id, "php://output", $file, FTP_BINARY);
    $data = ob_get_contents();
    $datasize = ob_get_length( );
    ob_end_clean();
    if ($result)
        return array( 'data' => $data, 'size' => $datasize );
    return null;
}


            $mapfile = SUPERFTP::getFtpFileContentsWithSize($ftpconn, $curmap['filename']);
            ftp_close($ftpconn);
            if (!$mapfile)
            {
                $viewParams['OutContext'] = "Error. File not found." ;
            }

            header('Content-Description: File Transfer');
            header('Content-Type: application/octet-stream');
            header('Content-Disposition: attachment; filename='.$curmap['filename']);
            header('Content-Transfer-Encoding: binary');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Pragma: public');
            header('Content-Length: ' . $mapfile['size']); 

            echo $mapfile['data'];
            exit( );

Mã này hoạt động. Cảm ơn tất cả.

Đã trả lời ngày 11 tháng 11 năm 2017 lúc 17:52Nov 11, 2017 at 17:52

Mavbad xấu MavBad Mav

Phù hiệu bạc 231 Huy hiệu đồng1 silver badge8 bronze badges

14 năm trước

mpatnode tại yahoo dot com ¶Downloads a file from the FTP server

4 năm trước

Miki tại epoch dot co dot il ¶(
    FTP\Connection $ftp,
    string $local_filename,
    string $remote_filename,
    int

ftp_get($conn_id, "php://output", $file, FTP_BINARY);
0 =
ftp_get($conn_id, "php://output", $file, FTP_BINARY);
1
,
    int
ftp_get($conn_id, "php://output", $file, FTP_BINARY);
2 = 0

): bool

Quản trị viên tại Gesoft Dot org ¶

16 năm trước

Corey-Holzer tại NYC Dot Rr dot comFTP\Connection instance.

18 năm trước

thivierr tại telus dot net ¶

Giáo xứ Ben ¶

Đường dẫn tệp từ xa.

ftp_get($conn_id, "php://output", $file, FTP_BINARY);
6

Chế độ chuyển. Phải là

ftp_get($conn_id, "php://output", $file, FTP_BINARY);
7 hoặc
ftp_get($conn_id, "php://output", $file, FTP_BINARY);
1.
ftp_get($conn_id, "php://output", $file, FTP_BINARY);
7
or
ftp_get($conn_id, "php://output", $file, FTP_BINARY);
1
.

ftp_get($conn_id, "php://output", $file, FTP_BINARY);
9

Vị trí trong tệp từ xa để bắt đầu tải xuống từ.

Trả về giá trị

Trả về

$conn_id = ftp_connect("ftp.example.com");
ftp_login($conn_id, "username", "password");
ftp_pasv($conn_id, true);

$file_path = "remote/path/file.zip";
$size = ftp_size($conn_id, $file_path);

header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=" . basename($file_path));
header("Content-Length: $size"); 

ftp_get($conn_id, "php://output", $file_path, FTP_BINARY);
0 khi thành công hoặc
$conn_id = ftp_connect("ftp.example.com");
ftp_login($conn_id, "username", "password");
ftp_pasv($conn_id, true);

$file_path = "remote/path/file.zip";
$size = ftp_size($conn_id, $file_path);

header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=" . basename($file_path));
header("Content-Length: $size"); 

ftp_get($conn_id, "php://output", $file_path, FTP_BINARY);
1 về thất bại.
$conn_id = ftp_connect("ftp.example.com");
ftp_login($conn_id, "username", "password");
ftp_pasv($conn_id, true);

$file_path = "remote/path/file.zip";
$size = ftp_size($conn_id, $file_path);

header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=" . basename($file_path));
header("Content-Length: $size"); 

ftp_get($conn_id, "php://output", $file_path, FTP_BINARY);
0
on success or
$conn_id = ftp_connect("ftp.example.com");
ftp_login($conn_id, "username", "password");
ftp_pasv($conn_id, true);

$file_path = "remote/path/file.zip";
$size = ftp_size($conn_id, $file_path);

header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=" . basename($file_path));
header("Content-Length: $size"); 

ftp_get($conn_id, "php://output", $file_path, FTP_BINARY);
1
on failure.

Thay đổi

Phiên bảnSự mô tả
8.1.0 Tham số
ftp_get($conn_id, "php://output", $file, FTP_BINARY);
3 mong đợi một thể hiện kết nối FTP \ ngay bây giờ; Trước đây, một tài nguyên đã được dự kiến.FTP\Connection instance now; previously, a resource was expected.
7.3.0 Tham số
ftp_get($conn_id, "php://output", $file, FTP_BINARY);
6 hiện là tùy chọn. Trước đây nó đã được bắt buộc.

Ví dụ

Ví dụ #1 ftp_get () ví dụftp_get() example

$conn_id = ftp_connect("ftp.example.com");
ftp_login($conn_id, "username", "password");
ftp_pasv($conn_id, true);

$file_path = "remote/path/file.zip";
$size = ftp_size($conn_id, $file_path);

header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=" . basename($file_path));
header("Content-Length: $size"); 

ftp_get($conn_id, "php://output", $file_path, FTP_BINARY);
4

Xem thêm

  • ftp_pasv () - Bật hoặc tắt chế độ thụ động
  • ftp_fget () - Tải xuống tệp từ máy chủ FTP và lưu vào tệp mở
  • ftp_nb_get () - Lấy một tệp từ máy chủ FTP và ghi nó vào tệp cục bộ (không chặn)
  • ftp_nb_fget () - Lấy một tệp từ máy chủ FTP và ghi nó vào một tệp mở (không chặn)

Cudi ¶

12 năm trước

$conn_id = ftp_connect("ftp.example.com");
ftp_login($conn_id, "username", "password");
ftp_pasv($conn_id, true);

$file_path = "remote/path/file.zip";
$size = ftp_size($conn_id, $file_path);

header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=" . basename($file_path));
header("Content-Length: $size"); 

ftp_get($conn_id, "php://output", $file_path, FTP_BINARY);
5

$conn_id = ftp_connect("ftp.example.com");
ftp_login($conn_id, "username", "password");
ftp_pasv($conn_id, true);

$file_path = "remote/path/file.zip";
$size = ftp_size($conn_id, $file_path);

header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=" . basename($file_path));
header("Content-Length: $size"); 

ftp_get($conn_id, "php://output", $file_path, FTP_BINARY);
6

$conn_id = ftp_connect("ftp.example.com");
ftp_login($conn_id, "username", "password");
ftp_pasv($conn_id, true);

$file_path = "remote/path/file.zip";
$size = ftp_size($conn_id, $file_path);

header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=" . basename($file_path));
header("Content-Length: $size"); 

ftp_get($conn_id, "php://output", $file_path, FTP_BINARY);
7

$conn_id = ftp_connect("ftp.example.com");
ftp_login($conn_id, "username", "password");
ftp_pasv($conn_id, true);

$file_path = "remote/path/file.zip";
$size = ftp_size($conn_id, $file_path);

header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=" . basename($file_path));
header("Content-Length: $size"); 

ftp_get($conn_id, "php://output", $file_path, FTP_BINARY);
8

$conn_id = ftp_connect("ftp.example.com");
ftp_login($conn_id, "username", "password");
ftp_pasv($conn_id, true);

$file_path = "remote/path/file.zip";
$size = ftp_size($conn_id, $file_path);

header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=" . basename($file_path));
header("Content-Length: $size"); 

ftp_get($conn_id, "php://output", $file_path, FTP_BINARY);
9

public static function getFtpFileContentsWithSize($conn_id , $file)
{
    ob_start();
    $result = ftp_get($conn_id, "php://output", $file, FTP_BINARY);
    $data = ob_get_contents();
    $datasize = ob_get_length( );
    ob_end_clean();
    if ($result)
        return array( 'data' => $data, 'size' => $datasize );
    return null;
}


            $mapfile = SUPERFTP::getFtpFileContentsWithSize($ftpconn, $curmap['filename']);
            ftp_close($ftpconn);
            if (!$mapfile)
            {
                $viewParams['OutContext'] = "Error. File not found." ;
            }

            header('Content-Description: File Transfer');
            header('Content-Type: application/octet-stream');
            header('Content-Disposition: attachment; filename='.$curmap['filename']);
            header('Content-Transfer-Encoding: binary');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Pragma: public');
            header('Content-Length: ' . $mapfile['size']); 

            echo $mapfile['data'];
            exit( );
0

public static function getFtpFileContentsWithSize($conn_id , $file)
{
    ob_start();
    $result = ftp_get($conn_id, "php://output", $file, FTP_BINARY);
    $data = ob_get_contents();
    $datasize = ob_get_length( );
    ob_end_clean();
    if ($result)
        return array( 'data' => $data, 'size' => $datasize );
    return null;
}


            $mapfile = SUPERFTP::getFtpFileContentsWithSize($ftpconn, $curmap['filename']);
            ftp_close($ftpconn);
            if (!$mapfile)
            {
                $viewParams['OutContext'] = "Error. File not found." ;
            }

            header('Content-Description: File Transfer');
            header('Content-Type: application/octet-stream');
            header('Content-Disposition: attachment; filename='.$curmap['filename']);
            header('Content-Transfer-Encoding: binary');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Pragma: public');
            header('Content-Length: ' . $mapfile['size']); 

            echo $mapfile['data'];
            exit( );
1

public static function getFtpFileContentsWithSize($conn_id , $file)
{
    ob_start();
    $result = ftp_get($conn_id, "php://output", $file, FTP_BINARY);
    $data = ob_get_contents();
    $datasize = ob_get_length( );
    ob_end_clean();
    if ($result)
        return array( 'data' => $data, 'size' => $datasize );
    return null;
}


            $mapfile = SUPERFTP::getFtpFileContentsWithSize($ftpconn, $curmap['filename']);
            ftp_close($ftpconn);
            if (!$mapfile)
            {
                $viewParams['OutContext'] = "Error. File not found." ;
            }

            header('Content-Description: File Transfer');
            header('Content-Type: application/octet-stream');
            header('Content-Disposition: attachment; filename='.$curmap['filename']);
            header('Content-Transfer-Encoding: binary');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Pragma: public');
            header('Content-Length: ' . $mapfile['size']); 

            echo $mapfile['data'];
            exit( );
2

Bob tại Notallhere dot com ¶

9 năm trước

public static function getFtpFileContentsWithSize($conn_id , $file)
{
    ob_start();
    $result = ftp_get($conn_id, "php://output", $file, FTP_BINARY);
    $data = ob_get_contents();
    $datasize = ob_get_length( );
    ob_end_clean();
    if ($result)
        return array( 'data' => $data, 'size' => $datasize );
    return null;
}


            $mapfile = SUPERFTP::getFtpFileContentsWithSize($ftpconn, $curmap['filename']);
            ftp_close($ftpconn);
            if (!$mapfile)
            {
                $viewParams['OutContext'] = "Error. File not found." ;
            }

            header('Content-Description: File Transfer');
            header('Content-Type: application/octet-stream');
            header('Content-Disposition: attachment; filename='.$curmap['filename']);
            header('Content-Transfer-Encoding: binary');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Pragma: public');
            header('Content-Length: ' . $mapfile['size']); 

            echo $mapfile['data'];
            exit( );
3

public static function getFtpFileContentsWithSize($conn_id , $file)
{
    ob_start();
    $result = ftp_get($conn_id, "php://output", $file, FTP_BINARY);
    $data = ob_get_contents();
    $datasize = ob_get_length( );
    ob_end_clean();
    if ($result)
        return array( 'data' => $data, 'size' => $datasize );
    return null;
}


            $mapfile = SUPERFTP::getFtpFileContentsWithSize($ftpconn, $curmap['filename']);
            ftp_close($ftpconn);
            if (!$mapfile)
            {
                $viewParams['OutContext'] = "Error. File not found." ;
            }

            header('Content-Description: File Transfer');
            header('Content-Type: application/octet-stream');
            header('Content-Disposition: attachment; filename='.$curmap['filename']);
            header('Content-Transfer-Encoding: binary');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Pragma: public');
            header('Content-Length: ' . $mapfile['size']); 

            echo $mapfile['data'];
            exit( );
4

public static function getFtpFileContentsWithSize($conn_id , $file)
{
    ob_start();
    $result = ftp_get($conn_id, "php://output", $file, FTP_BINARY);
    $data = ob_get_contents();
    $datasize = ob_get_length( );
    ob_end_clean();
    if ($result)
        return array( 'data' => $data, 'size' => $datasize );
    return null;
}


            $mapfile = SUPERFTP::getFtpFileContentsWithSize($ftpconn, $curmap['filename']);
            ftp_close($ftpconn);
            if (!$mapfile)
            {
                $viewParams['OutContext'] = "Error. File not found." ;
            }

            header('Content-Description: File Transfer');
            header('Content-Type: application/octet-stream');
            header('Content-Disposition: attachment; filename='.$curmap['filename']);
            header('Content-Transfer-Encoding: binary');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Pragma: public');
            header('Content-Length: ' . $mapfile['size']); 

            echo $mapfile['data'];
            exit( );
5

public static function getFtpFileContentsWithSize($conn_id , $file)
{
    ob_start();
    $result = ftp_get($conn_id, "php://output", $file, FTP_BINARY);
    $data = ob_get_contents();
    $datasize = ob_get_length( );
    ob_end_clean();
    if ($result)
        return array( 'data' => $data, 'size' => $datasize );
    return null;
}


            $mapfile = SUPERFTP::getFtpFileContentsWithSize($ftpconn, $curmap['filename']);
            ftp_close($ftpconn);
            if (!$mapfile)
            {
                $viewParams['OutContext'] = "Error. File not found." ;
            }

            header('Content-Description: File Transfer');
            header('Content-Type: application/octet-stream');
            header('Content-Disposition: attachment; filename='.$curmap['filename']);
            header('Content-Transfer-Encoding: binary');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Pragma: public');
            header('Content-Length: ' . $mapfile['size']); 

            echo $mapfile['data'];
            exit( );
2

Ramiro tại Qusarcr dot com

19 năm trước

public static function getFtpFileContentsWithSize($conn_id , $file)
{
    ob_start();
    $result = ftp_get($conn_id, "php://output", $file, FTP_BINARY);
    $data = ob_get_contents();
    $datasize = ob_get_length( );
    ob_end_clean();
    if ($result)
        return array( 'data' => $data, 'size' => $datasize );
    return null;
}


            $mapfile = SUPERFTP::getFtpFileContentsWithSize($ftpconn, $curmap['filename']);
            ftp_close($ftpconn);
            if (!$mapfile)
            {
                $viewParams['OutContext'] = "Error. File not found." ;
            }

            header('Content-Description: File Transfer');
            header('Content-Type: application/octet-stream');
            header('Content-Disposition: attachment; filename='.$curmap['filename']);
            header('Content-Transfer-Encoding: binary');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Pragma: public');
            header('Content-Length: ' . $mapfile['size']); 

            echo $mapfile['data'];
            exit( );
7

anomie tại người dùng dot sf dot net ¶

15 năm trước

public static function getFtpFileContentsWithSize($conn_id , $file)
{
    ob_start();
    $result = ftp_get($conn_id, "php://output", $file, FTP_BINARY);
    $data = ob_get_contents();
    $datasize = ob_get_length( );
    ob_end_clean();
    if ($result)
        return array( 'data' => $data, 'size' => $datasize );
    return null;
}


            $mapfile = SUPERFTP::getFtpFileContentsWithSize($ftpconn, $curmap['filename']);
            ftp_close($ftpconn);
            if (!$mapfile)
            {
                $viewParams['OutContext'] = "Error. File not found." ;
            }

            header('Content-Description: File Transfer');
            header('Content-Type: application/octet-stream');
            header('Content-Disposition: attachment; filename='.$curmap['filename']);
            header('Content-Transfer-Encoding: binary');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Pragma: public');
            header('Content-Length: ' . $mapfile['size']); 

            echo $mapfile['data'];
            exit( );
8

Nate từ Ruggf Family.com

13 năm trước

public static function getFtpFileContentsWithSize($conn_id , $file)
{
    ob_start();
    $result = ftp_get($conn_id, "php://output", $file, FTP_BINARY);
    $data = ob_get_contents();
    $datasize = ob_get_length( );
    ob_end_clean();
    if ($result)
        return array( 'data' => $data, 'size' => $datasize );
    return null;
}


            $mapfile = SUPERFTP::getFtpFileContentsWithSize($ftpconn, $curmap['filename']);
            ftp_close($ftpconn);
            if (!$mapfile)
            {
                $viewParams['OutContext'] = "Error. File not found." ;
            }

            header('Content-Description: File Transfer');
            header('Content-Type: application/octet-stream');
            header('Content-Disposition: attachment; filename='.$curmap['filename']);
            header('Content-Transfer-Encoding: binary');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Pragma: public');
            header('Content-Length: ' . $mapfile['size']); 

            echo $mapfile['data'];
            exit( );
9

ob_start()0

ob_start()1

ob_start()2

mroerick tại gmx dot net ¶

13 năm trước

ob_start()3

ob_start()4

ob_start()5

ob_start()6

mroerick tại gmx dot net ¶

Aditya P dot Bhatt (Adityabhai tại Gmail Dot Com) ¶

ob_start()7

ob_start()8

ob_start()9

14 năm trước

mpatnode tại yahoo dot com ¶

Content-Length0

4 năm trước

9 năm trước

Content-Length1

Content-Length2

public static function getFtpFileContentsWithSize($conn_id , $file)
{
    ob_start();
    $result = ftp_get($conn_id, "php://output", $file, FTP_BINARY);
    $data = ob_get_contents();
    $datasize = ob_get_length( );
    ob_end_clean();
    if ($result)
        return array( 'data' => $data, 'size' => $datasize );
    return null;
}


            $mapfile = SUPERFTP::getFtpFileContentsWithSize($ftpconn, $curmap['filename']);
            ftp_close($ftpconn);
            if (!$mapfile)
            {
                $viewParams['OutContext'] = "Error. File not found." ;
            }

            header('Content-Description: File Transfer');
            header('Content-Type: application/octet-stream');
            header('Content-Disposition: attachment; filename='.$curmap['filename']);
            header('Content-Transfer-Encoding: binary');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Pragma: public');
            header('Content-Length: ' . $mapfile['size']); 

            echo $mapfile['data'];
            exit( );
2

anomie tại người dùng dot sf dot net ¶

15 năm trước

Content-Length4

Nate từ Ruggf Family.com

13 năm trước

Content-Length5

Content-Length6

Content-Length7

Content-Length8

Content-Length9

ftp_size0

ftp_size1

public static function getFtpFileContentsWithSize($conn_id , $file)
{
    ob_start();
    $result = ftp_get($conn_id, "php://output", $file, FTP_BINARY);
    $data = ob_get_contents();
    $datasize = ob_get_length( );
    ob_end_clean();
    if ($result)
        return array( 'data' => $data, 'size' => $datasize );
    return null;
}


            $mapfile = SUPERFTP::getFtpFileContentsWithSize($ftpconn, $curmap['filename']);
            ftp_close($ftpconn);
            if (!$mapfile)
            {
                $viewParams['OutContext'] = "Error. File not found." ;
            }

            header('Content-Description: File Transfer');
            header('Content-Type: application/octet-stream');
            header('Content-Disposition: attachment; filename='.$curmap['filename']);
            header('Content-Transfer-Encoding: binary');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Pragma: public');
            header('Content-Length: ' . $mapfile['size']); 

            echo $mapfile['data'];
            exit( );
2

mroerick tại gmx dot net ¶

Aditya P dot Bhatt (Adityabhai tại Gmail Dot Com) ¶

ftp_size3

14 năm trước

Aditya P dot Bhatt (Adityabhai tại Gmail Dot Com) ¶

ftp_size4

ftp_size5

ftp_size6

public static function getFtpFileContentsWithSize($conn_id , $file)
{
    ob_start();
    $result = ftp_get($conn_id, "php://output", $file, FTP_BINARY);
    $data = ob_get_contents();
    $datasize = ob_get_length( );
    ob_end_clean();
    if ($result)
        return array( 'data' => $data, 'size' => $datasize );
    return null;
}


            $mapfile = SUPERFTP::getFtpFileContentsWithSize($ftpconn, $curmap['filename']);
            ftp_close($ftpconn);
            if (!$mapfile)
            {
                $viewParams['OutContext'] = "Error. File not found." ;
            }

            header('Content-Description: File Transfer');
            header('Content-Type: application/octet-stream');
            header('Content-Disposition: attachment; filename='.$curmap['filename']);
            header('Content-Transfer-Encoding: binary');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Pragma: public');
            header('Content-Length: ' . $mapfile['size']); 

            echo $mapfile['data'];
            exit( );
2

14 năm trước

mpatnode tại yahoo dot com ¶

ftp_size8

ftp_size9

public static function getFtpFileContentsWithSize($conn_id , $file)
{
    ob_start();
    $result = ftp_get($conn_id, "php://output", $file, FTP_BINARY);
    $data = ob_get_contents();
    $datasize = ob_get_length( );
    ob_end_clean();
    if ($result)
        return array( 'data' => $data, 'size' => $datasize );
    return null;
}


            $mapfile = SUPERFTP::getFtpFileContentsWithSize($ftpconn, $curmap['filename']);
            ftp_close($ftpconn);
            if (!$mapfile)
            {
                $viewParams['OutContext'] = "Error. File not found." ;
            }

            header('Content-Description: File Transfer');
            header('Content-Type: application/octet-stream');
            header('Content-Disposition: attachment; filename='.$curmap['filename']);
            header('Content-Transfer-Encoding: binary');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Pragma: public');
            header('Content-Length: ' . $mapfile['size']); 

            echo $mapfile['data'];
            exit( );
2

4 năm trước

mpatnode tại yahoo dot com ¶

$ftp1

$ftp2

$ftp3

$ftp4

public static function getFtpFileContentsWithSize($conn_id , $file)
{
    ob_start();
    $result = ftp_get($conn_id, "php://output", $file, FTP_BINARY);
    $data = ob_get_contents();
    $datasize = ob_get_length( );
    ob_end_clean();
    if ($result)
        return array( 'data' => $data, 'size' => $datasize );
    return null;
}


            $mapfile = SUPERFTP::getFtpFileContentsWithSize($ftpconn, $curmap['filename']);
            ftp_close($ftpconn);
            if (!$mapfile)
            {
                $viewParams['OutContext'] = "Error. File not found." ;
            }

            header('Content-Description: File Transfer');
            header('Content-Type: application/octet-stream');
            header('Content-Disposition: attachment; filename='.$curmap['filename']);
            header('Content-Transfer-Encoding: binary');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Pragma: public');
            header('Content-Length: ' . $mapfile['size']); 

            echo $mapfile['data'];
            exit( );
2

4 năm trước

Miki tại epoch dot co dot il ¶

$ftp6

$ftp7

$ftp8

public static function getFtpFileContentsWithSize($conn_id , $file)
{
    ob_start();
    $result = ftp_get($conn_id, "php://output", $file, FTP_BINARY);
    $data = ob_get_contents();
    $datasize = ob_get_length( );
    ob_end_clean();
    if ($result)
        return array( 'data' => $data, 'size' => $datasize );
    return null;
}


            $mapfile = SUPERFTP::getFtpFileContentsWithSize($ftpconn, $curmap['filename']);
            ftp_close($ftpconn);
            if (!$mapfile)
            {
                $viewParams['OutContext'] = "Error. File not found." ;
            }

            header('Content-Description: File Transfer');
            header('Content-Type: application/octet-stream');
            header('Content-Disposition: attachment; filename='.$curmap['filename']);
            header('Content-Transfer-Encoding: binary');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Pragma: public');
            header('Content-Length: ' . $mapfile['size']); 

            echo $mapfile['data'];
            exit( );
2

Quản trị viên tại Gesoft Dot org ¶

13 năm trước

$local_filename0

mroerick tại gmx dot net ¶

Aditya P dot Bhatt (Adityabhai tại Gmail Dot Com) ¶

$local_filename1

$local_filename2

public static function getFtpFileContentsWithSize($conn_id , $file)
{
    ob_start();
    $result = ftp_get($conn_id, "php://output", $file, FTP_BINARY);
    $data = ob_get_contents();
    $datasize = ob_get_length( );
    ob_end_clean();
    if ($result)
        return array( 'data' => $data, 'size' => $datasize );
    return null;
}


            $mapfile = SUPERFTP::getFtpFileContentsWithSize($ftpconn, $curmap['filename']);
            ftp_close($ftpconn);
            if (!$mapfile)
            {
                $viewParams['OutContext'] = "Error. File not found." ;
            }

            header('Content-Description: File Transfer');
            header('Content-Type: application/octet-stream');
            header('Content-Disposition: attachment; filename='.$curmap['filename']);
            header('Content-Transfer-Encoding: binary');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Pragma: public');
            header('Content-Length: ' . $mapfile['size']); 

            echo $mapfile['data'];
            exit( );
2