Home > Backend Development > PHP Tutorial > ftp_size() function in PHP

ftp_size() function in PHP

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2023-09-02 16:30:01
forward
1379 people have browsed it

ftp_size() function in PHP

The ftp_size() function is used to obtain the size of a specific file on the FTP server.

Syntax

ftp_size(conn, myfile)
Copy after login

Parameters

  • conn − FTP connection

  • myfile − Server file

Return value

The ftp_size() function returns the size (in bytes) of a specific file on success.

Example

The following is an example of getting the file size: "new.txt" −

<?php
   $ftp_server = "192.168.0.4";
   $ftp_user = "username";
   $ftp_pass = "gfhgfj236k";
   $conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
   $login = ftp_login($con, $ftp_user, $ftp_pass);
   $myfile = "new.txt";
   //size of $file
   $size = ftp_size($conn, $myfile);
   if ($size ! = -1) {
      echo "Size is $fsize bytes";
   } else {
      echo "Cannot get the file size!";
   }
   // close
   ftp_close($conn);
?>
Copy after login

The above is the detailed content of ftp_size() function in PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template