PHP ftp_alloc()ฟังก์ชัน
ตัวอย่าง
จัดสรรพื้นที่สำหรับไฟล์และอัปโหลดไฟล์ไปยังเซิร์ฟเวอร์ FTP:
<?php
// connect and login to FTP server
$ftp_server = "ftp.example.com";
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);
$file = "/test/myfile";
// allocate space
if (ftp_alloc($ftp_conn, filesize($file), $result))
{
echo "Space allocated on server. Sending $file.";
ftp_put($ftp_conn, "/files/myfile", $file, FTP_BINARY);
}
else
{
echo "Error! Server said: $result";
}
// close connection
ftp_close($ftp_conn);
?>
ความหมายและการใช้งาน
ฟังก์ชัน ftp_alloc() จัดสรรพื้นที่สำหรับไฟล์ที่จะอัปโหลดไปยังเซิร์ฟเวอร์ FTP
หมายเหตุ:เซิร์ฟเวอร์ FTP จำนวนมากไม่รองรับคำสั่งนี้!
ไวยากรณ์
ftp_alloc(ftp_conn, filesize, result);
ค่าพารามิเตอร์
Parameter | Description |
---|---|
ftp_conn | Required. Specifies the FTP connection to use |
filesize | Required. Specifies the number of bytes to allocate |
result | Optional. Specifies a variable to store the server response in |
รายละเอียดทางเทคนิค
คืนมูลค่า: | จริงกับความสำเร็จ เท็จเมื่อล้มเหลว |
---|---|
รุ่น PHP: | 5+ |
❮ การอ้างอิง PHP FTP