bubu Posted December 4, 2007 Report Share Posted December 4, 2007 Vai zini kā tulkojas angļu valodā teksts "File exists"? Tas nozīmē, ka fails jau eksistē! Link to comment Share on other sites More sharing options...
*jancis38* Posted December 4, 2007 Author Report Share Posted December 4, 2007 (edited) <?php mkdir ("fails",0755); if (file_exists($filename)) { echo "Fails pastāv."; } else { mkdir($filename); } ?> bļin to es saprotu! es tak skaidri un gaiši pateicu ka gribu errora kļūdu nomainīt! Edited December 4, 2007 by *jancis38* Link to comment Share on other sites More sharing options...
andrisp Posted December 4, 2007 Report Share Posted December 4, 2007 Nu bah - kāpēc tev tur ir tas pirmais mkdir ? Loģiskām domāšanas vispār nav ? Link to comment Share on other sites More sharing options...
*jancis38* Posted December 4, 2007 Author Report Share Posted December 4, 2007 tew pašam loģiska domāšana naw.? es gribu lai viņš testē kad taisa folderi ja tāds folderis jau pastāv tad lai viņš izmet normālu kļūdu, nevis šitādu: Warning: mkdir() [function.mkdir]: File exists in C:\Web\www\test.php on line 2 Link to comment Share on other sites More sharing options...
andrisp Posted December 4, 2007 Report Share Posted December 4, 2007 Man vairs nav ko teikt ..... $filename = 'tavs_nosaukums'; if (file_exists($filename)) { echo "Fails pastāv."; } else { mkdir($filename); } Link to comment Share on other sites More sharing options...
*jancis38* Posted December 4, 2007 Author Report Share Posted December 4, 2007 sry. liels paldies.. šobrīd garīgā naw. Link to comment Share on other sites More sharing options...
andrisp Posted December 4, 2007 Report Share Posted December 4, 2007 (edited) Drīzāk kaut kas cits nav. :P Bet nu labi - gadās. Edited December 4, 2007 by andrisp Link to comment Share on other sites More sharing options...
*jancis38* Posted December 6, 2007 Author Report Share Posted December 6, 2007 kā var izdarī tā, repsektīvi es caur to skriptu taisu folderi, un ja folderi meģīnu uztaisit ar nosaukumu *jancis38* princibā izveidot mapi ar simboliem * naw atkļauts, tātad ka var izdarit lai viņš izmet kļūdu, ka šādu simbolu naw atkļauts lietot, vai arī noņem tos simbolus un uztaisa mapi ar nosaukumu jancis38 ? Link to comment Share on other sites More sharing options...
bubu Posted December 6, 2007 Report Share Posted December 6, 2007 Jau n-reizes izrunāta tēma... Aizvieto stringā visus simbolus, kas nav atļauti uz kautko citu. Piemēram, ja ir atļauti tikai burtui a-z un cipari 0-9, tad: $text = preg_replace("/[^a-z0-9]/", "_", $text); Vai arī, ja gribi tikai pārbaudīt: if (preg_match("/[^a-z0-9]/", $text) > 0) { echo "Slikts teksts! Ej prom."; } Link to comment Share on other sites More sharing options...
andrisp Posted December 6, 2007 Report Share Posted December 6, 2007 Es iesaku atļaut tikai ar konkrētiem simboliem. Es droši vien būtu darījis šādi: if (!preg_match('/^[a-zA-Z0-9_-]+$/'), $file_name) { echo 'Neatljauti simboli!'; } Link to comment Share on other sites More sharing options...
Grey_Wolf Posted December 6, 2007 Report Share Posted December 6, 2007 + velams parbaudiit vai visi simboli nav ( _ ) ... --> itka korekti, bet apsaluti neko neisakoshi (iedomajies failnami ar ( _ ) 32 pasvitrojuma simboliem ;) + maksimalais garums (teiksim 16 simboli ....) Link to comment Share on other sites More sharing options...
*jancis38* Posted December 6, 2007 Author Report Share Posted December 6, 2007 es ierakstīju šitā: <?php $filename = "test" mkdir("$filename", "$filename = preg_replace('/[^a-z0-9]/', "_", $filename"); ?> bet nesanāca, uzmet kļūdu: Parse error: parse error, unexpected T_STRING in C:\Web\www\test.php on line 3 Link to comment Share on other sites More sharing options...
andrisp Posted December 6, 2007 Report Share Posted December 6, 2007 Sintakti jāmācās. Kāpēc centies php kodu iekš pēdiņām likt ? mkdir($filename, $filename = preg_replace('/[^a-z0-9]/', "_", $filename)); Link to comment Share on other sites More sharing options...
bubu Posted December 6, 2007 Report Share Posted December 6, 2007 Tev tur jocīgs mkdir funkcijas izsaukums. Normālā variantā vajag padot tikai vienu argumentu. Otru vajag, ja grib pieejas tiesības likt savādākas. Link to comment Share on other sites More sharing options...
*jancis38* Posted December 6, 2007 Author Report Share Posted December 6, 2007 tas pats. :/ Link to comment Share on other sites More sharing options...
Recommended Posts