Author Topic: Extern Filesize Info  (Read 6769 times)

0 Members and 1 Guest are viewing this topic.

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.806
  • I ♥ 4I
    • View Profile
Extern Filesize Info
« on: September 29, 2010, 10:16:27 PM »
I would be happy to spend an external file sizes, but I get an error message.

details.html

<?php
$datei 
"http://www.gaupc1.gina.servhost.biz/$server_pfad$image_server_file";
$groesse filesize("$datei");
echo 
"$groesse";
?>


Quote
Warning: filesize() [function.filesize]: stat failed for http://www.gaupc1.gina.servhost.biz/bf/bf1942/mappacks/iCe_D-Day_Map_Pack_2.zip in /is/htdocs/wp1189343_OX40HRKULQ/www/gau-pc/includes/template.php(101) : eval()'d code on line 212

Does the code somewhere else?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Extern Filesize Info
« Reply #1 on: September 30, 2010, 02:33:51 AM »
If you have PHP5, you can use get_headers() function:

function filesize_remote($url)
{
  
$headers get_headers($url1);
  return @
$headers['Content-Length'];
}
$datei "http://www.gaupc1.gina.servhost.biz/$server_pfad$image_server_file";
$groesse filesize_remote($datei);
echo 
$groesse;


P.S.
you don't need use quotes for variables.
echo "$var";
is the same as
echo $var;
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.806
  • I ♥ 4I
    • View Profile
Re: Extern Filesize Info
« Reply #2 on: September 30, 2010, 07:01:02 PM »
Thank you for your help
will be emitted so that only bytes. I would like but it is in MB or higher output.

How do I get it?

Now I use the following code

<?php
function filesize_remote($url)
{
  
$headers get_headers($url1);
  return @
$headers['Content-Length'];
}
$datei "http://www.gaupc1.gina.servhost.biz/$server_pfad$image_server_file";
$groesse filesize_remote($datei);

function 
byte_ausrechnen($byte) {
    
    if(
$byte 1024) {
        
$ergebnis round($byte2). ' Byte';
    }elseif(
$byte >= 1024 and $byte pow(10242)) {
        
$ergebnis round($byte/10242).' KByte';
    }elseif(
$byte >= pow(10242) and $byte pow(10243)) {
        
$ergebnis round($byte/pow(10242), 2).' MByte';
    }elseif(
$byte >= pow(10243) and $byte pow(10244)) {
        
$ergebnis round($byte/pow(10243), 2).' GByte';
    }elseif(
$byte >= pow(10244) and $byte pow(10245)) {
        
$ergebnis round($byte/pow(10244), 2).' TByte';
    }elseif(
$byte >= pow(10245) and $byte pow(10246)) {
        
$ergebnis round($byte/pow(10245), 2).' PByte';
    }elseif(
$byte >= pow(10246) and $byte pow(10247)) {
        
$ergebnis round($byte/pow(10246), 2).' EByte';
    }

return 
$ergebnis;
    
}

//Beispiel:
$var1 $groesse;

echo 
byte_ausrechnen($var1);
?>


The issue is not true. Do you have a solution?

Rembrandt

  • Guest
Re: Extern Filesize Info
« Reply #3 on: September 30, 2010, 07:13:10 PM »
...
The issue is not true. Do you have a solution?

probier das mal:

function byte_ausrechnen($size)
 {
    
$unit=array('b','kb','mb','gb','tb','pb');
    return @
round($size/pow(1024,($i=floor(log($size,1024)))),3).' '.$unit[$i];
 }

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.806
  • I ♥ 4I
    • View Profile
Re: Extern Filesize Info
« Reply #4 on: September 30, 2010, 10:03:21 PM »
Vielen Dank,
aber sag mal. Ist es möglich eine Nachricht auszugeben wenn ein File nicht vorhanden ist?
Denn in Moment ist das so, dass mir dann eine Fehlermeldung ausgegeben wird wie
Quote
Warning: get_headers() [function.get-headers]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /is/htdocs/wp1189343_OX40HRKULQ/www/gau-pc/includes/template.php(101) : eval()'d code on line 213

Warning: get_headers(http://www.&nbsp;bf/bf1942/mods/dc_final_client.exe) [function.get-headers]: failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /is/htdocs/wp1189343_OX40HRKULQ/www/gau-pc/includes/template.php(101) : eval()'d code on line 213
Eine Fehlermeldung alá "Größe konnte nicht berechnet werden" oderso wäre besser

Rembrandt

  • Guest
Re: Extern Filesize Info
« Reply #5 on: September 30, 2010, 10:36:59 PM »

$datei 
"http://www.gaupc1.gina.servhost.biz/$server_pfad$image_server_file";
  if (
fopen($datei"r")) {  
   
$groesse filesize_remote($datei);
  }
  else {  
   echo 
"Datei oder Link nicht vorhanden";  
  }  


kann aber sein das der server wegen "fopen" streikt.

zitat:
Quote
Wenn Sie Safe Mode oder open_basedir aktiviert haben, können weitere Einschränkungen zutreffen.
 


Offline sigma.

  • Full Member
  • ***
  • Posts: 148
  • cydonian.com/potd
    • View Profile
    • sigma's gallery
Re: Extern Filesize Info
« Reply #6 on: December 31, 2010, 08:27:19 PM »
Can anyone advise if this works? I need to have something similar. File Size field for an external / different download for the image in the details page. Right now I have a manual field for pixel size and thats a pain, don't want to have another pain for adding file size manually.