Tôi đang sử dụng định dạng sau trong mã PHP để tải xuống các tệp từ máy chủ FTP.
Tôi đang gặp lỗi 550 vì tên tệp chứa '#'. Làm thế nào để tránh lỗi. Ngoài ra lớp PHP tốt nhất để thực hiện các hoạt động khác nhau trên FTP là gì?
10 năm trước
Apurvavora19 tại gmail dot com ¶ — Downloads a file from the FTP server
Scott Dot Chu tại Udngroup Dot Com ¶
6 năm trước(
FTP\Connection $ftp
,
string
$local_filename
,
string $remote_filename
,
int $mode
= FTP_BINARY
,
int $offset
= 0
): bool
w dot danford tại điện tử-software dot com ¶
Danny tại Ingeniarte dot com ¶11 năm trướcFTP\Connection instance.
Làm thế nào để tải xuống tệp từ FTP trong PHP?Hàm ftp_get () được sử dụng để tải xuống một tệp từ máy chủ FTP. Hàm ftp_get () lấy một tệp từ xa từ máy chủ FTP và lưu nó vào một tệp cục bộ. Chức năng này đã được giới thiệu trong PHP 4.
Làm cách nào để tải xuống các tệp từ máy chủ FTP?Tải lên và tải xuống một tệp lên/từ máy chủ FTP.
Điều hướng đến thư mục từ xa nơi tệp bạn muốn tải xuống,.Điều hướng đến thư mục cục bộ nơi bạn muốn lưu trữ tệp đã tải xuống,.<?php
// define some variables
$local_file = 'filename.jpg';
$server_file = 'filename.jpg';
$ftp_server="www.abc.com";
$ftp_user_name="username";
$ftp_user_pass="password";
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// try to download $server_file and save to $local_file
if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
echo "Successfully written to $local_file\n";
}
else {
echo "There was a problem\n";
}
// close the connection
ftp_close($conn_id);
?>
4 or FTP_BINARY
.
Chọn tệp bạn muốn tải xuống từ thư mục từ xa và ..Nhấp vào nút tải xuống ..
Làm cách nào để tải xuống một tệp từ dòng lệnh FTP?
Cho tiện ích dòng lệnh FTP.<?php
// define some variables
$local_file = 'filename.jpg';
$server_file = 'filename.jpg';
$ftp_server="www.abc.com";
$ftp_user_name="username";
$ftp_user_pass="password";
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// try to download $server_file and save to $local_file
if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
echo "Successfully written to $local_file\n";
}
else {
echo "There was a problem\n";
}
// close the connection
ftp_close($conn_id);
?>
7 on success or <?php
// define some variables
$local_file = 'filename.jpg';
$server_file = 'filename.jpg';
$ftp_server="www.abc.com";
$ftp_user_name="username";
$ftp_user_pass="password";
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// try to download $server_file and save to $local_file
if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
echo "Successfully written to $local_file\n";
}
else {
echo "There was a problem\n";
}
// close the connection
ftp_close($conn_id);
?>
8 on failure.
Nhập một trong các lệnh FTP sau đây để liệt kê các tệp trong thư mục phụ chính sách: Dir. ls ..
Nhập lệnh FTP sau để bắt đầu tải xuống tệp: Nhận tên tệp. Tệp đã tải xuống được đặt trong thư mục hiện tại trong đó chương trình FTP được khởi chạy trên hệ thống của bạn .. | Scott Dot Chu tại Udngroup Dot Com ¶ |
---|
8.1.0 | 6 năm trướcFTP\Connection instance now; previously, a resource was expected.
|
7.3.0 | w dot danford tại điện tử-software dot com ¶ |
Danny tại Ingeniarte dot com ¶
11 năm trướcftp_get() example
true == (
$data = @
file_get_contents('ftp://username:password@server_name/folder_name/xyz#123.csv')
)
?
file_put_contents('xyz#123.csv', $data)
:
exit;
1Làm thế nào để tải xuống tệp từ FTP trong PHP?
- Hàm ftp_get () được sử dụng để tải xuống một tệp từ máy chủ FTP. Hàm ftp_get () lấy một tệp từ xa từ máy chủ FTP và lưu nó vào một tệp cục bộ. Chức năng này đã được giới thiệu trong PHP 4.
- 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 ¶ ¶
13 năm trước
true == (
$data = @
file_get_contents('ftp://username:password@server_name/folder_name/xyz#123.csv')
)
?
file_put_contents('xyz#123.csv', $data)
:
exit;
2true == (
$data = @
file_get_contents('ftp://username:password@server_name/folder_name/xyz#123.csv')
)
?
file_put_contents('xyz#123.csv', $data)
:
exit;
3true == (
$data = @
file_get_contents('ftp://username:password@server_name/folder_name/xyz#123.csv')
)
?
file_put_contents('xyz#123.csv', $data)
:
exit;
4true == (
$data = @
file_get_contents('ftp://username:password@server_name/folder_name/xyz#123.csv')
)
?
file_put_contents('xyz#123.csv', $data)
:
exit;
5true == (
$data = @
file_get_contents('ftp://username:password@server_name/folder_name/xyz#123.csv')
)
?
file_put_contents('xyz#123.csv', $data)
:
exit;
6true == (
$data = @
file_get_contents('ftp://username:password@server_name/folder_name/xyz#123.csv')
)
?
file_put_contents('xyz#123.csv', $data)
:
exit;
7true == (
$data = @
file_get_contents('ftp://username:password@server_name/folder_name/xyz#123.csv')
)
?
file_put_contents('xyz#123.csv', $data)
:
exit;
8true == (
$data = @
file_get_contents('ftp://username:password@server_name/folder_name/xyz#123.csv')
)
?
file_put_contents('xyz#123.csv', $data)
:
exit;
9 Bob tại Notallhere dot com ¶ ¶
9 năm trước
$output = exec("wget -N ftp:///path/to directory/file 2>&1 |grep 'filename w/o extension'|grep -v ftp|grep -v =");
print $output <to check if file downloaded or not>
0$output = exec("wget -N ftp:///path/to directory/file 2>&1 |grep 'filename w/o extension'|grep -v ftp|grep -v =");
print $output <to check if file downloaded or not>
1$output = exec("wget -N ftp:///path/to directory/file 2>&1 |grep 'filename w/o extension'|grep -v ftp|grep -v =");
print $output <to check if file downloaded or not>
2true == (
$data = @
file_get_contents('ftp://username:password@server_name/folder_name/xyz#123.csv')
)
?
file_put_contents('xyz#123.csv', $data)
:
exit;
9 Ramiro tại Qusarcr dot com ¶
19 năm trước
$output = exec("wget -N ftp:///path/to directory/file 2>&1 |grep 'filename w/o extension'|grep -v ftp|grep -v =");
print $output <to check if file downloaded or not>
4 anomie tại người dùng dot sf dot net ¶ ¶
15 năm trước
$output = exec("wget -N ftp:///path/to directory/file 2>&1 |grep 'filename w/o extension'|grep -v ftp|grep -v =");
print $output <to check if file downloaded or not>
5 Nate từ Ruggf Family.com ¶
14 năm trước
$output = exec("wget -N ftp:///path/to directory/file 2>&1 |grep 'filename w/o extension'|grep -v ftp|grep -v =");
print $output <to check if file downloaded or not>
6$output = exec("wget -N ftp:///path/to directory/file 2>&1 |grep 'filename w/o extension'|grep -v ftp|grep -v =");
print $output <to check if file downloaded or not>
7$output = exec("wget -N ftp:///path/to directory/file 2>&1 |grep 'filename w/o extension'|grep -v ftp|grep -v =");
print $output <to check if file downloaded or not>
8$output = exec("wget -N ftp:///path/to directory/file 2>&1 |grep 'filename w/o extension'|grep -v ftp|grep -v =");
print $output <to check if file downloaded or not>
9 mroerick tại gmx dot net ¶ ¶
13 năm trước
$ftp
0
$ftp
1
$ftp
2
$ftp
3 Aditya P dot Bhatt (Adityabhai tại Gmail Dot Com) ¶ ¶
14 năm trước
$ftp
4
$ftp
5
$ftp
6 mpatnode tại yahoo dot com ¶ ¶
4 năm trước
$ftp
7
Miki tại epoch dot co dot il ¶ ¶
9 năm trước
$ftp
8
$ftp
9
true == (
$data = @
file_get_contents('ftp://username:password@server_name/folder_name/xyz#123.csv')
)
?
file_put_contents('xyz#123.csv', $data)
:
exit;
9 anomie tại người dùng dot sf dot net ¶ ¶
15 năm trước
$local_filename
1
Quản trị viên tại Gesoft Dot org ¶ ¶
16 năm trước
$local_filename
2
$local_filename
3
$local_filename
4
$local_filename
5
$local_filename
6
$local_filename
7
$local_filename
8
true == (
$data = @
file_get_contents('ftp://username:password@server_name/folder_name/xyz#123.csv')
)
?
file_put_contents('xyz#123.csv', $data)
:
exit;
9 Corey-Holzer tại NYC Dot Rr dot com ¶
18 năm trước
$remote_filename
0
thivierr tại telus dot net ¶ ¶
18 năm trước
$remote_filename
1
$remote_filename
2
$remote_filename
3
true == (
$data = @
file_get_contents('ftp://username:password@server_name/folder_name/xyz#123.csv')
)
?
file_put_contents('xyz#123.csv', $data)
:
exit;
9 thivierr tại telus dot net ¶ ¶
Giáo xứ Ben ¶
$remote_filename
5
$remote_filename
6
true == (
$data = @
file_get_contents('ftp://username:password@server_name/folder_name/xyz#123.csv')
)
?
file_put_contents('xyz#123.csv', $data)
:
exit;
9 10 năm trước ¶
4 năm trước
$remote_filename
8
$remote_filename
9
$mode
0
$mode
1
true == (
$data = @
file_get_contents('ftp://username:password@server_name/folder_name/xyz#123.csv')
)
?
file_put_contents('xyz#123.csv', $data)
:
exit;
9 Miki tại epoch dot co dot il ¶ ¶
9 năm trước
$mode
3
$mode
4
$mode
5
true == (
$data = @
file_get_contents('ftp://username:password@server_name/folder_name/xyz#123.csv')
)
?
file_put_contents('xyz#123.csv', $data)
:
exit;
9
anomie tại người dùng dot sf dot net ¶ ¶
15 năm trước
$mode
7
Quản trị viên tại Gesoft Dot org ¶
¶
16 năm trước
$mode
8
$mode
9
true == (
$data = @
file_get_contents('ftp://username:password@server_name/folder_name/xyz#123.csv')
)
?
file_put_contents('xyz#123.csv', $data)
:
exit;
9