Tôi có hai máy chủ. Tôi đã có một tệp .txt trong tệp tôi đang kết nối.
Tôi cần lấy nội dung tệp .txt và đặt chúng vào biến $
. Đây là mã của tôi không hoạt động:
$ftp_server = $_POST["site"];
$path = $_POST["path"];
$ftp_user_name = $_POST["username"];
$ftp_user_pass = $_POST["pass"];
// set up basic connection
$conn_id = ftp_connect[$ftp_server];
// login with username and password
$login_result = ftp_login[$conn_id, $ftp_user_name, $ftp_user_pass];
$remote_filename =
"/" . $_POST["path"] . "/" . "#" . $result["id"]
. " - " . $result["LastName"] . ", " . $result["FirstName"]
. "/" . $_POST["title"] . ".txt";
ftp_get[$conn_id, $content, $remote_filename, FTP_ASCII];
Mã này kết nối với FTP và tôi đã sử dụng ftp_get
để sao chép từ một tệp văn bản sang một biến gọi là $content
. Tôi biết một biến không thuộc về tham số này, nhưng tôi được bán ngay bây giờ. Tôi không biết làm thế nào để đọc tệp .txt này.
Có cách nào để làm điều này với các chức năng PHP FTP không?
Bây giờ, khi tôi thử điều này:
$fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
Nó gây ra lỗi:
Cảnh báo: Fopen [FTP: /// 101NoteBook sao lưu: 22-08-2013/#11-Cappucci, Ryan/Queen.txt] [function.fopen] 08-2013/: Không phải là một tệp thông thường trong /home/content/34/11614434/html/adminpdo.php trên dòng 269
Tại sao tôi nhận được lỗi này?
Cảm ơn một lần nữa
[Php 4, Php 5, Php 7, Php 8]
FTP_GET - Tải xuống tệp từ máy chủ FTP — Downloads a file from the FTP server
Sự mô tả
ftp_get [& nbsp; & nbsp; & nbsp; & nbsp; ftp \ Connection ________ 5, & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; int
0 = 0]: bool[$fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
FTP\Connection $ftp
,
string
$local_filename
,
string $remote_filename
,
int $mode
= FTP_BINARY
,
int
0 = 0$fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
]: bool
Thông số
$fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
1Một thể hiện kết nối ftp \.FTP\Connection instance.
$fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
2Đường dẫn tệp cục bộ [sẽ được ghi đè nếu tệp đã tồn tại].
$fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
3Đường dẫn tệp từ xa.
$fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
4Chế độ chuyển. Phải là
$fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
5 hoặc FTP_BINARY
.$fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
5 or FTP_BINARY
. $fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
7Vị trí trong tệp từ xa để bắt đầu tải xuống từ.
Trả về giá trị
Trả về
$fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
8 khi thành công hoặc $fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
9 về thất bại.$fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
8 on success or $fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
9 on failure. Thay đổi
8.1.0 | ftp_get [& nbsp; & nbsp; & nbsp; & nbsp; ftp \ Connection ________ 5, & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; int 0 = 0]: boolFTP\Connection instance now; previously, a resource was expected.
|
7.3.0 | Thông số |
$fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
1
$fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
Một thể hiện kết nối ftp \.ftp_get[] example
$
2
$fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
2
$fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
- Đường dẫn tệp cục bộ [sẽ được ghi đè nếu tệp đã tồn tại].
-
3$fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
- Đường dẫn tệp từ xa.
-
4$fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
Chế độ chuyển. Phải là
5 hoặc $fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
FTP_BINARY
. ¶
7$fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
$
3
$
4
$
5
$
6
$
7
$
8
$
9
ftp_get
0Vị trí trong tệp từ xa để bắt đầu tải xuống từ. ¶
Trả về giá trị
ftp_get
1
ftp_get
2
ftp_get
3
ftp_get
0 Trả về
8 khi thành công hoặc $fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
9 về thất bại. ¶$fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
Thay đổi
ftp_get
5
Phiên bản ¶
Tham số
1 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.$fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
ftp_get
6
Tham số
4 hiện là tùy chọn. Trước đây nó đã được bắt buộc. ¶$fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
14 năm trước
ftp_get
7
ftp_get
8
ftp_get
9
$content
0Danny tại Ingeniarte dot com ¶ ¶
7$fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
$content
1
$content
2
$content
3
$content
4Vị trí trong tệp từ xa để bắt đầu tải xuống từ. ¶
14 năm trước
$content
5
$content
6
$content
7Danny tại Ingeniarte dot com ¶ ¶
4 năm trước
$content
8
Scott Dot Chu tại Udngroup Dot Com ¶ ¶
Trả về giá trị
$content
9
$ftp
0
ftp_get
0Phiên bản ¶
Tham số
1 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.$fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
$ftp
2
Tham số
4 hiện là tùy chọn. Trước đây nó đã được bắt buộc. ¶$fileContents = file_get_contents['ftp://username:password@hostname/path/to/file'];
Ví dụ
$ftp
3
$ftp
4
$ftp
5
$ftp
6
$ftp
7
$ftp
8
$ftp
9
ftp_get
0Corey-Holzer tại NYC Dot Rr dot com ¶
18 năm trước
$local_filename
1
thivierr tại telus dot net ¶ ¶
19 năm trước
$local_filename
2
$local_filename
3
$local_filename
4
ftp_get
0Giáo xứ Ben ¶ ¶
10 năm trước
$local_filename
6
$local_filename
7
ftp_get
0Apurvavora19 tại gmail dot com ¶ ¶
4 năm trước
$local_filename
9
$remote_filename
0
$remote_filename
1
$remote_filename
2
ftp_get
0Scott Dot Chu tại Udngroup Dot Com ¶ ¶
6 năm trước
$remote_filename
4
$remote_filename
5
$remote_filename
6
ftp_get
0w dot danford tại điện tử-software dot com ¶ ¶
14 năm trước
$remote_filename
8
Danny tại Ingeniarte dot com ¶ ¶
11 năm trước
$remote_filename
9
$mode
0
ftp_get
0