ziedinjsh Posted September 24, 2009 Report Share Posted September 24, 2009 Šāds ir cods: <?php $dir = "./mp3"; $dh = opendir($dir); while (($file = readdir($dh)) !== false) { echo "<A HREF=\"$file\">$file</A><BR>\n"; } closedir($dh); ?> Viņš parādā failu kas atrodas mp3 folderī. Tas viss ir labi, bet zem faila viņš rāda vēl divus linkus .. un . kā viņus var noņemt un kā var piešķirt katram failam id? Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted September 24, 2009 Report Share Posted September 24, 2009 Par id... nesapratu. Par nerādīšanu if($file != '.' && file !='..'){ echo "<A HREF=\"$file\">$file</A><BR>\n"; } Quote Link to comment Share on other sites More sharing options...
marcis Posted September 24, 2009 Report Share Posted September 24, 2009 Arī readdir() manuāli netrūkst piemēru :) Bet varbūt labāk tev derētu izmantot glob() funckciju? Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted September 24, 2009 Author Report Share Posted September 24, 2009 Lieta tāda piemērām es tagad uztaisu linku šādu <a href='mp3/$file'>$file</a> atverot pirmkodu es redzu ka ir links <a href='http://mp3.domens.lv/mp3/dziesmas_nosaukums.mp3'>dziesmas nosaukums.mp3</a> bet pie flash playera <embed src="http://www.strangecube.com/audioplay/online/audioplay.swf?file=mp3/$file&auto=no&sendstop=yes&repeat=1.... vai <embed src="http://www.strangecube.com/audioplay/online/audioplay.swf?file=http://mp3.domens.lv/mp3/$file&auto=no&sendstop=yes&repeat=1... man neuzrādās links un tapēc neskan.. skatoties caur pirmkodu tur arī tā pat rādas mp3/$file ?? kapēc tā? Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted September 24, 2009 Report Share Posted September 24, 2009 Parādi pilnu echo rindiņu. Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted September 24, 2009 Author Report Share Posted September 24, 2009 Es atveinojos par savu muļķīgo kļūdu.. bet playera kodu biju ielicis starp ?> un <?php tākā viņš nemaz $file nevarēja nolasīt Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted September 24, 2009 Author Report Share Posted September 24, 2009 kā es piemēram no $file faila varu izņem tārā simbolu _ un aizivietot ar tukšumu vienkāršī? Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted September 24, 2009 Report Share Posted September 24, 2009 http://lv.php.net/manual/en/function.str-replace.php Quote Link to comment Share on other sites More sharing options...
pingvīns Posted September 24, 2009 Report Share Posted September 24, 2009 Gardēžiem :) $dir = new DirectoryIterator(dirname(__FILE__)); foreach ($dir as $fileinfo) { if (!$fileinfo->isDot()) { var_dump($fileinfo->getFilename()); } } Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted September 25, 2009 Author Report Share Posted September 25, 2009 kas man jāpievieno lai rādītos failam arī links ar kuru es varu izdzēst failu no foldera? Quote Link to comment Share on other sites More sharing options...
waplet Posted September 25, 2009 Report Share Posted September 25, 2009 unlink($file); http://lv.php.net/unlink Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted September 27, 2009 Author Report Share Posted September 27, 2009 un kā es varu to unlink ievietot linkā lai viņš izdzēš šo $file? Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted October 5, 2009 Author Report Share Posted October 5, 2009 kko biju uztaisījis linka veidīgu, bet kad uzpieda dzēst viņš izdzēsa visus failus uzreiz Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted October 5, 2009 Report Share Posted October 5, 2009 Tieši tā notiek, kad taisa "kaut ko" un nevis precīzi "to, ko vajag". Ja parādītu to "kaut ko", ko sataisīji, iespējams, varētu palīdzēt pārveidot par "to, ko vajag". Quote Link to comment Share on other sites More sharing options...
direktorss Posted October 5, 2009 Report Share Posted October 5, 2009 Man tas tavs kods strādā šitā <?php $dir = "w"; $dh = opendir($dir); while (($file = readdir($dh)) !== false) { echo "<A HREF=\"$dir\">$file</A><BR>\n"; } closedir($dh); ?> Nezinu ko tu tur īsti gribi uztaisīt ,bet failu lasa šādi. 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.