<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Cancellazione multipla file tramite checkboxes]]></title><description><![CDATA[<p dir="auto">Ciao a tutti,<br />
sto implementando una funzione php per la cancellazione multipla di immagini dentro una cartella con l' utilizzo delle checkboxes. Il mio problema è che la cancellazione dei file non è multipla ma singola.<br />
Di seguito la funziona che stampa le immagini presenti nella dir:</p>
<p dir="auto">&lt;?php<br />
$folder_path = '../images/'; //image's folder path<br />
switch($_POST['PAGE'])<br />
{<br />
case "intro":<br />
$folder_path .= "intro/";<br />
break;</p>
<p dir="auto">case "story":<br />
default:<br />
$folder_path .="story/";<br />
break;<br />
}</p>
<p dir="auto">$num_files = glob($folder_path . "*.{JPG,jpg,gif,png,bmp}", GLOB_BRACE);</p>
<p dir="auto">$folder = opendir($folder_path);</p>
<p dir="auto">if($num_files &gt; 0)<br />
{<br />
while(false !== ($file = readdir($folder)))<br />
{</p>
<pre><code> /*$foil = strstr($file, 'jpg'); 
 $foil = $file; */
</code></pre>
<p dir="auto">$file_path = $folder_path.$file;<br />
$extension = strtolower(pathinfo($file ,PATHINFO_EXTENSION));<br />
if($extension=='jpg' || $extension =='png' || $extension == 'gif' || $extension == 'bmp')<br />
{<br />
?&gt;</p>
<p dir="auto">&lt;div class="multi-col"&gt;<br />
&lt;form action="delete_image.php" method="post"&gt;<br />
&lt;input class="checkbox" type="checkbox" name="check_list[]" value="&lt;?php echo $file_path; ?&gt;" /&gt;&lt;?php echo "&lt;img width='200' height='150' src='$file_path' /&gt;";?&gt;<br />
&lt;input type="submit" value="Delete Image" name="delete"&gt;<br />
&lt;/form&gt;<br />
&lt;/div&gt;</p>
<pre><code>    &lt;?php       
</code></pre>
<p dir="auto">}<br />
}<br />
}</p>
<p dir="auto">closedir($folder);<br />
?&gt;</p>
<p dir="auto">A seguire il file delete.php:</p>
<p dir="auto">&lt;?php</p>
<p dir="auto">/<em>------------------------</em>/</p>
<p dir="auto">if(!empty($_POST['check_list'])) {<br />
// Counting number of checked checkboxes.<br />
$checked_count = count($_POST['check_list']);<br />
echo $checked_count;<br />
echo "You have selected following ".$checked_count." option(s): &lt;br/&gt;";<br />
// Loop to store and display values of individual checked checkbox.<br />
foreach($_POST['check_list'] as $selected) {<br />
echo "&lt;p&gt;".$selected ."&lt;/p&gt;";<br />
}</p>
<p dir="auto">if(isset($_POST['delete'])){<br />
if (file_exists($selected)) {<br />
unlink("$selected");<br />
echo '&lt;script language="javascript"&gt;';<br />
echo 'alert("File eliminato con successo")';<br />
echo '&lt;/script&gt;';<br />
echo "&lt;script&gt;window.location.href = '../pages/intro_upload.php';&lt;/script&gt;";<br />
}</p>
<p dir="auto">echo "&lt;br/&gt;&lt;b&gt;Note :&lt;/b&gt; &lt;span&gt;Similarily, You Can Also Perform CRUD Operations using These Selected Values.&lt;/span&gt;";<br />
}<br />
else{<br />
echo "&lt;b&gt;Please Select Atleast One Option.&lt;/b&gt;";<br />
}<br />
}<br />
?&gt;</p>
<p dir="auto">Vorrei inoltre capire come ottenere un solo bottone Cancel preposto alla cancellazione multipla perchè allo stato attuale vengono generati tanti bottoni cancel quanti sono i file stampati a video.<br />
Grazie!</p>
]]></description><link>https://connect.gt/topic/221368/cancellazione-multipla-file-tramite-checkboxes</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Jul 2026 05:01:47 GMT</lastBuildDate><atom:link href="https://connect.gt/topic/221368.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 25 Feb 2016 10:54:49 GMT</pubDate><ttl>60</ttl></channel></rss>