#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Posts
    79
    Rep Power
    15
    Hi guys and gals.

    Im wondering if its possible to retrieve the filesize of a remote file without having to download the whole file from my script.

    Any help would be much appreciated.


    Basil
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Posts
    79
    Rep Power
    15
    Its ok, the problem has been solved.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Location
    Beijing,PRC
    Posts
    7
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by 'tantrum:
    Its ok, the problem has been solved.[/quote]

    but how ?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Posts
    79
    Rep Power
    15
    ok heres the solution..

    $imgPath = '/foo/bar.gif'; // remote location
    $imgHost = "www.foo.com";
    $fp = fsockopen($imgHost, 80, &$errno, &$errstr, 30);
    if(!$fp) {
    echo "ERROR: $errno: $errstr";
    } else {
    fputs($fp,"HEAD $imgPath HTTP/1.0nHost: $imgHostnn");
    while(!feof($fp)) {
    $response .= fgets($fp,128);
    }
    fclose($fp);
    }
    $imgSz = ereg_replace("(.*)(Content-Length: )([0-9]*)(.*)","3",$response);

    This is an extract of some code i found.
    This works with all types of files...but I have been told it doesnt work with ALL remote servers.

    Basil

Similar Threads

  1. Pointer problem in opening a file
    By LAKI in forum C Programming
    Replies: 13
    Last Post: February 11th, 2004, 09:27 AM
  2. Pointer problems opening file *formatted*
    By LAKI in forum C Programming
    Replies: 4
    Last Post: February 11th, 2004, 07:06 AM
  3. PHP file upload script trouble
    By casbboy in forum PHP Development
    Replies: 9
    Last Post: February 5th, 2004, 08:42 PM
  4. remote file manipulation
    By Adren in forum PHP Development
    Replies: 2
    Last Post: January 24th, 2004, 12:42 PM
  5. Submit file to a remote form
    By NVme in forum PHP Development
    Replies: 0
    Last Post: January 19th, 2004, 11:57 AM

IMN logo majestic logo threadwatch logo seochat tools logo