PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

ftell> <fseek
Last updated: Sun, 25 Nov 2007

view this page in

fstat

(PHP 4, PHP 5)

fstat — 오픈 파일 포인터를 사용하는 파일에 대한 정보 가져오기

Description

array fstat ( int $fp )

파일 포인터 fp에 의해서 열려진 파일의 정보를 모읍니다.Gathers the statistics of the file opened by the file 이 함수는 filename대신에 오픈 파일 포인터위에서 동작한다는 것을 제외하고는 stat()과 비슷합니다.

다음의 요소들과 함께 파일의 통계자료를 배열로 반환합니다:

  1. 장치(device)
  2. 아이노드
  3. 링크의 갯수
  4. 소유자의 user id
  5. 소유자의 group id
  6. 아이노드 장치(device)가 있으면 장치(device) 형태*
  7. 바이트단위 크기
  8. 마지막 접근시간
  9. 마지막 수정된 시간
  10. 마지막 바뀐 시간
  11. 파일 시스템 입출력(I/O) blocksize*
  12. 할당된 block의 수
* - st_blksize 형태를 지원하는 시스템에만 유효합니다--다른 시스템 (다시 말해서 윈도우즈같은)은 -1을 반환합니다

이 함수의 실행결과는 캐시가 됩니다. 좀 더 자세히 알고 싶으면 clearstatcache()참조하세요



ftell> <fseek
Last updated: Sun, 25 Nov 2007
 
add a note add a note User Contributed Notes
fstat
broom at alturnanetworks dot com
03-Oct-2008 03:21
Another ftp_get_contents() approach, using a temperary stream handler. Returns file contents of remote file as string.

<?php
function ftp_get_contents ($conn_id, $remote_filename) {
   
//Create temp handler:
   
$tempHandle = fopen('php://temp', 'r+');

   
//Get file from FTP assuming that it exists:
   
ftp_fget($conn_id, $tempHandle, $remote_filename, FTP_ASCII, 0));

   
//Getting detailed stats to check filesize:
   
$fstats = fstat($tempHandle);

    return
fread($tempHandle, $fstats['size']);
}
?>

(It is recommended to add some error handling)
mordae at mordae dot net
29-Jan-2006 07:12
dom at dodgydom dot com wrote:
Best way i found was to open the url into $data and make a temporary file with the contents of $data then get the fstats on the temporary file :).

OMG why? The only thing that will remain is the file size. You also download up to 1G file, which probably is not what you want.

To get size use PHP's function filesize() with URL wrappers or ask yourself via HTTP.
sheran at comtrust dot co dot ae
21-Feb-2001 05:14
On Windows NT the typical array element names for the fstat function are:

dev
ino
mode
nlink
uid
gid
size
atime
mtime
ctime

ftell> <fseek
Last updated: Sun, 25 Nov 2007
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites