Re: FW: looking for two remote functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/10/07, Németh Zoltán <znemeth@xxxxxxxxxxxxxx> wrote:

2007. 03. 10, szombat keltezéssel 12.42-kor Riyadh S. Alshaeiq ezt írta:
> Actually if right click on any file or folder on a machine you will see
that
> there are two values (Size on disk & Size). Files and folders are stored
on
> the disk in what is called clusters (a group of disk sectors). Size on
disk
> refers to the amount of cluster allocation a file is taking up, compared
to
> file size which is an actual byte count.
>
> As I mentioned before what I want is a function for getting the result
for
> the Size no for Size on Disk

okay then what about this?

function real_filesize_linux($file) {
      @exec("filesize $file",$out,$ret);
      if ( $ret <> '0' ) return FALSE;
      else return($out[0]);
}

if you want it on a remote machine, you should use something like
ssh2_exec() instead of exec()

hope that helps
Zoltán Németh


He was interested on using it over HTTP, not over SSH...
I don't know if there are faster ways, but you could open a socket to the
host on port 80, get the file, and only read the header where it says
content-length: 400 for example, then you know the file is 400bytes when you
download it.
something like:
$socket = fsockopen($host,$port);
$size = 0;
while($size == 0)
{
$line = fgets($socket);
if(strlen($line) >= 17)
{
if(substr(strtolower($line),0,14) == "content-length")
{
$size = substr($line,16)
}
}

Now your remote file size is in $size.
It is not too fast, but everything in PHP is fast and so is this.

Tijnema


>
> Riyadh
>
> -----Original Message-----
> From: Németh Zolt?n [mailto:znemeth@xxxxxxxxxxxxxx]
> Sent: 10/Mar/2007 12:27 PM
> To: Riyadh S. Alshaeiq
> Cc: php-general@xxxxxxxxxxxxx
> Subject: Re:  FW: looking for two remote functions
>
> I'm afraid I don't understand what you want. The size of a file is its
> size in bytes, that is its size on the disk. So what else?
>
> greets
> Zolt?n Németh
>
> 2007. 03. 10, szombat keltezéssel 06.07-kor Riyadh S. Alshaeiq ezt ?rta:
> > Thank you Mickey, but I have already looked in there and the function
> posted
> > in the notes is working just fine for getting the size on disk which I
am
> > not interested in..
> >
> > Riyadh
> >
> > -----Original Message-----
> > From: Mikey [mailto:frak@xxxxxxxxxx]
> > Sent: 9/Mar/2007 2:57 PM
> > To: php-general@xxxxxxxxxxxxx
> > Subject: Re: looking for two remote functions
> >
> > Riyadh S. Alshaeiq wrote:
> > > Hello everybody,
> > >
> > >  I am looking for an HTTP function for getting remote filesizes.
Keeping
> > in
> > > mind that I am NOT interested in getting the "size on disk" figure,
I
> need
> > > the actual size of the files when downloaded to a local machine.
Please
> > let
> > > me know if there are any..
> > >
> > > Another thing, I also need a remote function that gets the created
date
> > and
> > > last modified separately, if possible..
> > >
> > > Best regards
> > >
> > >
> > >
> > >
> >
> > Try looking here:
> >
> > http://uk.php.net/manual/en/function.filesize.php
> >
> > If the function itself isn't of use to you, look further down in the
> > notes and I am sure you will find something useful.
> >
> > Mikey
> >
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux