*jancis38* Posted November 30, 2007 Report Posted November 30, 2007 1. Vai nav kādam gadijumā aizķēries kāds skripts, ar kura palīdzību var uploudot bildi, ar noteiktu nosaukumu... 2. Kā ir iespējams uploudoto bildi dzēst? (caur bruwseri.)
Delfins Posted November 30, 2007 Report Posted November 30, 2007 1.) if (filename != "kaka.jpg") die("merglis") 2.) unlink(filename)
blackhalt Posted November 30, 2007 Report Posted November 30, 2007 <input type="file" name="file" /> ... $sex=$_FILES['file']['name']; if($sex!='sex.png'){ print_r($_FILES); die('atļaujam tikai bildes ar nosaukumu sex.png'); }
marcis Posted November 30, 2007 Report Posted November 30, 2007 vispār jau pilns gūglis ar šitiem skriptiem un forumā arī daudzreiz aprunāta tēma dzēst failu: http://lv2.php.net/manual/en/function.unlink.php uploadot failus: http://www.google.lv/search?hl=lv&q=ph...A1ana&meta=
*jancis38* Posted November 30, 2007 Author Report Posted November 30, 2007 kkas man nesanāk... kas man būtu jaieraksta, lai skripts strādātu pēc manis prasītā.? index.php: <form enctype="multipart/form-data" action="upload.php" method="POST"> File: <input name="fails" type="file"><br> <input type="submit" value="Upload File"> </form> upload.php: <?php if (isset($_FILES['fails'])) { if ($_FILES['fails']['size']>1024*1024*100) { echo "Faila izmērs ir par lielu!"; } else { move_uploaded_file($_FILES['fails']['tmp_name'], "faili/".$_FILES['fails']['name']); echo "Fails veiksmīgi uploudots."; } } ?>
MC_ Posted November 30, 2007 Report Posted November 30, 2007 1. Ja izstrādā uz linux/unix parliecinies vai mapei /faili ir write tiesibas (rwxr-xr-x, 0775) 2. Korektāk būtu norādīt pilnu ceļu uz upload direktoriju piem. "/www/faili/".$_FILES['fails']['name'] uz win tad attiecigi "C:\\www_root\\faili\\".$_FILES['fails']['name'] 3. Ja uploado failu - pārliecinies, ka formā netiks uploadots evils scripts 4. paskaties ko saka var_dump($_FILES) pirms move_uploaded_file
blackhalt Posted November 30, 2007 Report Posted November 30, 2007 http://lv.php.net/manual/en/features.file-upload.php
*jancis38* Posted November 30, 2007 Author Report Posted November 30, 2007 (edited) ok, ar bilžu noteikto nosaukuma pievienošanu sanāca.. tgd es tikai nesaprotu kā uploudoto bildi var izdzēst. :/ EDITED: caur brūvseri. Edited November 30, 2007 by *jancis38*
blackhalt Posted November 30, 2007 Report Posted November 30, 2007 (edited) Kurā brīdī izdzēst? To vienīgo, kas tikko ir uplodota vai ka? http://lv.php.net/manual/en/function.unlink.php <?php $pats=$_SERVER['PHP_SELF']; $dir='images'; foreach (glob("$dir/*") as $file) { echo '<p><a href="'.$pats.'?dzest='.$file.'">'.$file.'</a></p>'; } if(isset($_GET['dzest'])){ unlink($_GET['dzest']); } ?> Edited November 30, 2007 by blackhalt
Recommended Posts