PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 12th, 2004, 01:08 PM
littleblackdog littleblackdog is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Anchorage
Posts: 118 littleblackdog User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
unlink function for multiple files

I am looking for a way to unlink files with a check box for multiple files. Users upload files, then need a way to unlink them, to clear up old newsletters.

I display the files, then follow each file with a check box, but I'm lost as how to process the box to loop through an unlink function.

If anyone has seen such a script, please point me in the right direction.
__________________
bow wow!

Reply With Quote
  #2  
Old August 12th, 2004, 03:12 PM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information. Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 992 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 732741 Folding Title: Super Ultimate Folder - Level 2Folding Points: 732741 Folding Title: Super Ultimate Folder - Level 2Folding Points: 732741 Folding Title: Super Ultimate Folder - Level 2Folding Points: 732741 Folding Title: Super Ultimate Folder - Level 2Folding Points: 732741 Folding Title: Super Ultimate Folder - Level 2Folding Points: 732741 Folding Title: Super Ultimate Folder - Level 2Folding Points: 732741 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 13 h 37 m 16 sec
Reputation Power: 5
Send a message via ICQ to Itsacon
I'd say, give each checkbox a name that can be traced back to the filename, and cycle through the $_POST[] array, filtering out things that aren't checkboxes.

Reply With Quote
  #3  
Old August 13th, 2004, 01:25 AM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
Here is a sample of what you can do... I supplied you with enough code to test this puppy out... you will need to write the functionality that iterates through the associative array and delete each file:

Code:
<?php
  if (isset($_POST['delete']) && $_POST['delete']=='yes') {
    print '<pre>';
    print_r($_POST['checkbox']);
    print '</pre>';
    exit;
  }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
 
<body>
<form name="form1" id="form1" method="post" action="">
<input type="hidden" name="delete" value="yes" />
  <p>
    <input name="checkbox[file1.jpg]" type="checkbox" id="checkbox[file1.jpg]" value="checkbox" />
  file1</p>
  <p>
    <input name="checkbox[file2.jpg]" type="checkbox" id="checkbox[file2.jpg]" value="checkbox" />
  file 2</p>
  <p>
    <input name="checkbox[file3.jpg]" type="checkbox" id="checkbox[file3.jpg]" value="checkbox" />
    file 3
 </p>
<input type="submit">
</form>
</body>
</html>
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #4  
Old August 13th, 2004, 01:27 AM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
As a side note, what the above code does is the following:

1 - The form has checkboxes which act as an associative array when sent to the php script. 'checkbox'. In each of the array indexes you have the name of the file such as 'file1.jpg'.

2 - The script finds that you would like to process the delete functionality and just loops through the indexes of the checkbox array which is actually inside the $_POST array. (superglobal array).

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > unlink function for multiple files


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway