PHP ftp_size() Function
Definition and Usage
The ftp_size() function returns the size of the specified file.
Syntax
ftp_size(ftp_connection,remote_file)
Parameters | Description |
---|---|
ftp_connection | Required. Specifies the FTP connection to be used (the identifier of the FTP connection). |
remote_file | Required. Specifies the file to be checked. |
Description
The ftp_size() function returns the size of the remote file in bytes remote_file size. If the specified file does not exist or an error occurs, it returns -1. Some FTP servers may not support this feature.
If the retrieval is successful, it returns the file size, otherwise it returns -1.
Tips and Comments
Note:Not all FTP servers support this function.
Example
<?php $conn = ftp_connect("ftp.testftp.com") or die("Could not connect"); ftp_login($conn,"admin","ert456"); echo ftp_size($conn,"test.txt"); ftp_close($conn); ?>
Output similar to:
160