dlmaster Posted February 17, 2008 Share Posted February 17, 2008 ... while (read from directory) { <tr> <td valign="middle" align="center"><img src="<?php echo $dir.$f ?>" border="0" /></td> <td valign="middle" align="center"> <input type="checkbox" name="delete[]" value="<?php echo $filename ?>"> </td></tr> <?php increment the counter; } closedir( $dir ); ?> This the code where I display the thumbnails for user to delete them.. and below is the the code to delete the files... if((isset($_REQUEST['delete2'])) && (!empty($_REQUEST['delete2'])) ) { $name = $_REQUEST['name']; $address = $_REQUEST['address']; $id= $_REQUEST['usr']; $add= $_REQUEST['add']; print_r($_REQUEST); foreach($_REQUEST['delete2'] as $file) { echo $file; $fstring = substr($file, 0, -3); $fext = substr($file, strrpos($file, '.')+1 ); $f= $fstring.$fext; echo 'Deleting file [' . $f . '] ... '; some delete sql statement unlink ($name."/".$address.'/'.$f); unlink($name."/".$address.'/thumb/'.$f); echo 'Done!<br />'; echo '<meta http-equiv="refresh" content="4;url=home.php?usr='.$id.'&addr='.$add.'">'; } } My question is why after pressing the delete button (submit the form), I cannot get the value of $file. After I press the delete button, it will show me : Array ( [usr] => 4 [addr] => test [delete2] => Array ( [0] => [1] => ) [address] => 3 [name] => li [add] => test [phpSESSID] => 407518078be038c4babd9e7446da5ca7 ) Deleting file [] ... Please help me... I have used this code in somewhere else in other pages. It worked.. Thank you in advance.. Quote Link to comment Share on other sites More sharing options...
Rithiur Posted February 17, 2008 Share Posted February 17, 2008 Are you sure that the checkboxes have any value in the form? It also appreas that in your form there you have delete[] as the value, while you are referring to delete2 in your code. Also, It's better if you post the actual code and not pseudocode. The error may where you don't expect it to be, but it's hard to point it out, if you only post what you think is significant. 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.