waplet Posted September 30, 2009 Report Share Posted September 30, 2009 nu itkā no attiecīgās valsts vai taka grupas kurā pieņems kā raksta tos skaitļus, vai ar punktu vai komatu Quote Link to comment Share on other sites More sharing options...
Snaip3Rs Posted September 30, 2009 Author Report Share Posted September 30, 2009 Es zinu cik ir viena mb un gb bet lūdzu pasakiet funkciju ka var dabut faila izmeru mb piemeram tur text.txt failam lai rada nevis baytus bet mb Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted September 30, 2009 Report Share Posted September 30, 2009 Funkcija ir aritmētiskā dalīšana. To apzīmē ar slīpsvītru / izmers_kilobaitos = izmers_baitos / 1024; izmers_megabaitos = izmers_kilobaitos / 1024; īsumā šādi: $mervienibas = Array('B', 'kB', 'MB', 'GB', 'TB'); //domājams, ka par terabaitu lielāku failu pagaidām Tev nebūs. $izmers = funkcija_kas_dabu_izmeru_baitos(); $mervienibas_indekss = 0; //Uzskatam, ka fails ir pietiekami mazs, lai būtu mazāks par 1024B. while($izmers > 1024){ $mervienibas_indekss++; $izmers=$izmers/1024; } if($mervienibas_indekss > 0){ //tātad ir bijusi dalīšana un vajag noapaļot līdz smukam izskatam, teiksim, divām zīmēm aiz punkta $izmers = round($izmers,2); } echo 'Izmērs: ' . $izmers . ' ' . $mervienibas[$mervienibas_indekss]; Quote Link to comment Share on other sites More sharing options...
Snaip3Rs Posted October 1, 2009 Author Report Share Posted October 1, 2009 Paldies ka palīdzēji bet man nesanāk vari salikt to kodu kopā ar failu! fails ko liek iznešanai <p><a href="countdownloads.php">Download File</a><br /> <?php $myFile = "counter.txt"; $fh = fopen($myFile, 'r'); $theData = fread($fh, filesize($myFile)); echo $theData; fclose($fh); ?> lejuplades<br /></p> fails kurā liek failu <?php $myFile = "counter.txt"; $fh = fopen($myFile, 'r'); $theData = fread($fh, filesize($myFile)); fclose($fh); $theData = $theData + 1; $myFile = "counter.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); fwrite($fh, $theData); fclose($fh); header("Location: deathrun_lv_zone.rar"); ?> lūdzu palīdzi-Aleksej jo citi tur tik kautko stast bet nerada ka to izdarīt! Quote Link to comment Share on other sites More sharing options...
briedis Posted October 1, 2009 Report Share Posted October 1, 2009 Jā Aleksej, palīdzi viņam! :) Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted October 2, 2009 Report Share Posted October 2, 2009 Nezinu i ko teikt... Es tajā kodā neredzu nevienu vietu, kur izvadītu/ierakstītu faila izmēru. Quote Link to comment Share on other sites More sharing options...
Snaip3Rs Posted October 2, 2009 Author Report Share Posted October 2, 2009 Atvaino aleksej es ieliku nepareizo kodu tur es visu meginaju un bija izdzisis! <p><a href="countdownloads.php">Download File</a><br /> <?php $myFile = "counter.txt"; $fh = fopen($myFile, 'r'); $theData = fread($fh, filesize($myFile)); echo $theData; fclose($fh); ?> lejuplades<br /></p> <p><?php echo filesize("deathrun_lv_zone.rar"); ?> Izmers<br /></p> Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted October 2, 2009 Report Share Posted October 2, 2009 rindiņas echo filesize("deathrun_lv_zone.rar"); vietā ieliec manu kodu. Līdz ar to funkcija_kas_dabu_izmeru_baitos(); faktiski ir funkcija filesize(); Quote Link to comment Share on other sites More sharing options...
Snaip3Rs Posted October 3, 2009 Author Report Share Posted October 3, 2009 Liels paldies vis strādā, bet ir viens "bet" cilvēki jau neliek vienu failu lejuplādēt tam nav jēga es jau vēlos likt vairākus failus lejuplādēt, bet nācu pie secinājuma ja es vēlos vairākus failus man jātaisa daudzas counter direktorijas tapē labāk nevarētu kautko savadāk izdarīt jo katram failam vajadzētu savu txt dokumentu gur glabāt. Ko jūs ieteiktu lai nevajadzētu taisīt txt failus vairākus! Izvada <table> <tr> <td> <a href="countdownloads.php">Download File</a> </td> <td> <?php $myFile = "counter.txt"; $fh = fopen($myFile, 'r'); $theData = fread($fh, filesize($myFile)); echo $theData; fclose($fh); ?> lejuplades </td> <td> <?php $mervienibas = Array('B', 'kB', 'MB', 'GB', 'TB'); //dom?jams, ka par terabaitu liel?ku failu pagaid?m Tev neb?s. $izmers=filesize('mani_faili/deathrun_lv_zone.rar'); $mervienibas_indekss = 0; //Uzskatam, ka fails ir pietiekami mazs, lai b?tu maz?ks par 1024B. while($izmers > 1024){ $mervienibas_indekss++; $izmers=$izmers/1024; } if($mervienibas_indekss > 0){ //t?tad ir bijusi dal??ana un vajag noapa?ot l?dz smukam izskatam, teiksim, div?m z?m?m aiz punkta $izmers = round($izmers,0); } echo '' . $izmers . ' ' . $mervienibas[$mervienibas_indekss]; ?> </td> <td> 30-07-2009 </td> </tr> </br> <tr> <td> <a href="countdownloads.php">Download File</a> </td> <td> <?php $myFile = "counter.txt"; $fh = fopen($myFile, 'r'); $theData = fread($fh, filesize($myFile)); echo $theData; fclose($fh); ?> lejuplades </td> <td> <?php $mervienibas = Array('B', 'kB', 'MB', 'GB', 'TB'); //dom?jams, ka par terabaitu liel?ku failu pagaid?m Tev neb?s. $izmers=filesize('mani_faili/cs_backround_maker_30_install.exe'); $mervienibas_indekss = 0; //Uzskatam, ka fails ir pietiekami mazs, lai b?tu maz?ks par 1024B. while($izmers > 1024){ $mervienibas_indekss++; $izmers=$izmers/1024; } if($mervienibas_indekss > 0){ //t?tad ir bijusi dal??ana un vajag noapa?ot l?dz smukam izskatam, teiksim, div?m z?m?m aiz punkta $izmers = round($izmers,0); } echo '' . $izmers . ' ' . $mervienibas[$mervienibas_indekss]; ?> </td> <td> 30-07-2009 </td> </tr> </table> glabāšanas funkcija <?php $myFile = "counter.txt"; $fh = fopen($myFile, 'r'); $theData = fread($fh, filesize($myFile)); fclose($fh); $theData = $theData + 1; $myFile = "counter.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); fwrite($fh, $theData); fclose($fh); header("Location: mani_faili/deathrun_lv_zone.rar"); ?> <?php $myFile = "counter.txt"; $fh = fopen($myFile, 'r'); $theData = fread($fh, filesize($myFile)); fclose($fh); $theData = $theData + 1; $myFile = "counter.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); fwrite($fh, $theData); fclose($fh); header("Location: mani_faili/cs_backround_maker_30_install.exe"); ?> Quote Link to comment Share on other sites More sharing options...
direktorss Posted October 3, 2009 Report Share Posted October 3, 2009 Patiesība ir šeit Quote Link to comment Share on other sites More sharing options...
Snaip3Rs Posted October 4, 2009 Author Report Share Posted October 4, 2009 Nelīdzēja!!! man saglaba abos klat nevis tikai vienam! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.