php - Problems with unlinking more than one picture at a time -


i have problem unlinking more 1 picture @ time. deleting folder name of picture(s) recived $_post "command". when print_r("the $_post here"); shows (with more 1 picture): foldername/picture1.jpgfoldername/picture2.jpg. why not work delete more 1 picture @ time?

i using code delete picture(s), picture(s) name(s) recived mysql table:

if ($_post["examplepost"]) {         // delete picture(s) $maal = $row_examplerow['picture'];  if (file_exists($maal)) {     unlink($maal);   } } 

http://php.net/manual/en/function.unlink.php

unlink() supports 1 file only.

there 2 approaches might want consider.

approach 1 sending them in form input[]

<form method='post'>     <input name='filename[]'><br/>     <input name='filename[]'><br/>     <input name='filename[]'><br/>     <input name='filename[]'><br/>     <input name='filename[]'><br/>     <input name='filename[]'><br/>     <input type=submit> </form> 

then might post array in php script.

   array (size=1)   'filename' =>      array (size=6)       0 => string 'aw' (length=2)       1 => string 'awf' (length=3)       2 => string 'fawf' (length=4)       3 => string '' (length=0)       4 => string '' (length=0)       5 => string '' (length=0) 

approach 2 might need parse incoming string. explode(',' , $_post['filenames']) , if comma separated.

<form method='post'>     <input name='filenames'>     <input type=submit> </form> 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -