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ỏ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
0 = ftp_get[$conn_id, "php://output", $file, FTP_BINARY];
1,ftp_get[$conn_id, "php://output", $file, FTP_BINARY];
int
2 = 0ftp_get[$conn_id, "php://output", $file, FTP_BINARY];
]: bool
Quản trị viên tại Gesoft Dot org ¶
16 năm trướcCorey-Holzer tại NYC Dot Rr dot comFTP\Connection instance.
18 năm trướcthivierr tại telus dot net ¶
Đường dẫn tệp từ xa.
ftp_get[$conn_id, "php://output", $file, FTP_BINARY];
6Chế độ 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];
9Vị 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
8.1.0 | Tham số 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ố 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];
4Xem 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];
9public 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[ ];
0public 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[ ];
1public 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[ ];
2Bob 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[ ];
3public 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[ ];
4public 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[ ];
5public 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[ ];
2Ramiro 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[ ];
7anomie 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[ ];
8Nate 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[ ];
9ob_start[]
0
ob_start[]
1
ob_start[]
2mroerick tại gmx dot net ¶ ¶
13 năm trước
ob_start[]
3
ob_start[]
4
ob_start[]
5
ob_start[]
6mroerick tại gmx dot net ¶ ¶
Aditya P dot Bhatt [Adityabhai tại Gmail Dot Com] ¶
ob_start[]
7
ob_start[]
8
ob_start[]
914 năm trước ¶
mpatnode tại yahoo dot com ¶
Content-Length
0
4 năm trước ¶
9 năm trước
Content-Length
1
Content-Length
2
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[ ];
2anomie tại người dùng dot sf dot net ¶ ¶
15 năm trước
Content-Length
4
Nate từ Ruggf Family.com ¶
13 năm trước
Content-Length
5
Content-Length
6
Content-Length
7
Content-Length
8
Content-Length
9
ftp_size
0
ftp_size
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[ ];
2mroerick tại gmx dot net ¶ ¶
Aditya P dot Bhatt [Adityabhai tại Gmail Dot Com] ¶
ftp_size
3
14 năm trước ¶
Aditya P dot Bhatt [Adityabhai tại Gmail Dot Com] ¶
ftp_size
4
ftp_size
5
ftp_size
6
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[ ];
214 năm trước ¶
mpatnode tại yahoo dot com ¶
ftp_size
8
ftp_size
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[ ];
24 năm trước ¶
mpatnode tại yahoo dot com ¶
$ftp
1
$ftp
2
$ftp
3
$ftp
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[ ];
24 năm trước ¶
Miki tại epoch dot co dot il ¶
$ftp
6
$ftp
7
$ftp
8
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[ ];
2Quản trị viên tại Gesoft Dot org ¶ ¶
13 năm trước
$local_filename
0
mroerick tại gmx dot net ¶ ¶
Aditya P dot Bhatt [Adityabhai tại Gmail Dot Com] ¶
$local_filename
1
$local_filename
2
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