Current location: Hot Scripts Forums » General Community » Script Requests » Script to view and delete images in a directory

Script to view and delete images in a directory

Reply
  #1 (permalink)  
Old 10-06-09, 03:10 PM
sac0o01 sac0o01 is offline
Newbie Coder
 
Join Date: Jul 2009
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
Script to view and delete images in a directory

I have searched high and low for a script that will return previews of all image files within a folder and then provide means to delete unwanted images. I have found several here that perform the preview function or allow delete from a list but none that perform both.

Seems like there should be something already written for this. Does anybody know of any scripts like this?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 10-06-09, 07:56 PM
ruteckycs's Avatar
ruteckycs ruteckycs is offline
Coding Addict
 
Join Date: Jul 2009
Posts: 273
Thanks: 3
Thanked 5 Times in 5 Posts
No but I could write you a basic one in PHP if you want. (for free of course) This is easy.
__________________
This post was created with 100% recycled electrons.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 10-07-09, 08:01 AM
sac0o01 sac0o01 is offline
Newbie Coder
 
Join Date: Jul 2009
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
That would be great! Thanks! It wouldn't have to be fancy or even have any security. I could just FTP it into the folder, clean up the files and then remove it again.

I have tried myself to combine two different scripts but I am afraid my Php skills have a long way to go yet.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 10-07-09, 08:40 AM
ruteckycs's Avatar
ruteckycs ruteckycs is offline
Coding Addict
 
Join Date: Jul 2009
Posts: 273
Thanks: 3
Thanked 5 Times in 5 Posts
Shoot me an email and Ill send it to you so you can FTP, then well post the code here for everyone else as well.

Rutecky Design and Print
__________________
This post was created with 100% recycled electrons.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 10-07-09, 08:56 AM
ruteckycs's Avatar
ruteckycs ruteckycs is offline
Coding Addict
 
Join Date: Jul 2009
Posts: 273
Thanks: 3
Thanked 5 Times in 5 Posts
2 scripts for this:

save as view.php
PHP Code:
<?php
$path
='images/';// change the path here related to this page
$handle=opendir($path);

while ((
$file readdir($handle))!==false) {
if(
strlen($file>3)){echo "

<img src=$path$file> <br>
<form action=\"delete.php\" method=\"post\">
<input type=\"hidden\" name=\"Name\" value=\"$pathfile\">
<input type=\"submit\" value=\"Delete\">
</form>

"
;}


}
closedir($handle);
?>
save as delete.php

PHP Code:
<?php
$path
='images/';// change the path here where images are
$Name=$_POST['Name'];

$PathFIle=$path.$Name;

unlink('$PathFile');

header('Location: view.php');
?>
There isnt any styling for the output, there is no security .. you can add these things yourself.Make sure you edit the path section the the directory where your images are. This code is untested but should be fine.
__________________
This post was created with 100% recycled electrons.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 10-07-09, 12:31 PM
sac0o01 sac0o01 is offline
Newbie Coder
 
Join Date: Jul 2009
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
Ok... I dropped the two files into the same folder as the images and set the path to: './'

The view function works great but when I hist the button to delete I get this error:

Code:
Warning: unlink($PathFile) [function.unlink]: No such file or directory in /home2/freefor3/public_html/bannerv2/images_saved/delete.php on line 7

Warning: Cannot modify header information - headers already sent by (output started at /home2/freefor3/public_html/bannerv2/images_saved/delete.php:1) in /home2/freefor3/public_html/bannerv2/images_saved/delete.php on line 9
Thanks for all the help, I really appreciate it!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 10-07-09, 01:00 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 7,536
Thanks: 5
Thanked 17 Times in 16 Posts
In view.php, replace this line:
PHP Code:
if(strlen($file>3)){echo 
... with:
PHP Code:
if (is_file($file)) { echo 
And
PHP Code:
<input type="hidden\" name=\"Name\" value=\"$pathfile\"> 
... with
PHP Code:
<input type="hidden\" name=\"Name\" value=\"$file\"> 
And in delete.php, replace this:
PHP Code:
unlink('$PathFile'); 
... with:
PHP Code:
$PathFile basename($PathFile);

if (
is_file($PathFile))
    
unlink($PathFile); 
(Variables aren't parsed between single quotes.)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 10-07-09, 01:41 PM
sac0o01 sac0o01 is offline
Newbie Coder
 
Join Date: Jul 2009
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
Still getting this:

Warning: Cannot modify header information - headers already sent by (output started at /home2/freefor3/public_html/bannerv2/images_saved/delete.php:1) in /home2/freefor3/public_html/bannerv2/images_saved/delete.php on line 12

Here is what I have so far:

view.php
PHP Code:
<?php
$path
='./'// change the path here related to this page
$handle=opendir($path);

while ((
$file readdir($handle))!==false) {
if (
is_file($file)) { echo "

<img src=$path$file> <br>
<form action=\"delete.php\" method=\"post\">
<input type=\"hidden\" name=\"Name\" value=\"$file\">  
<input type=\"submit\" value=\"Delete\">
</form>

"
;}


}
closedir($handle);
?>
and delete.php
PHP Code:
<?php
$path
='./';// change the path here where images are
$Name=$_POST['Name'];

$PathFIle=$path.$Name;

$PathFile basename($PathFile); 

if (
is_file($PathFile)) 
    
unlink($PathFile);  

header('Location: view.php');
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 10-07-09, 03:21 PM
sac0o01 sac0o01 is offline
Newbie Coder
 
Join Date: Jul 2009
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
Fixed the error message...had a whitespace problem.

Now the view.php works well. It displays the images along with the delete button. However when the delete button is pressed the page refreshes back to view.php and the image still exists.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 10-07-09, 09:50 PM
sac0o01 sac0o01 is offline
Newbie Coder
 
Join Date: Jul 2009
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
I found the problem. Works great!!! Thanks for all your help.

The error was caused by this:
PHP Code:
$PathFIle=$path.$Name
Changed it to this and it works great!
PHP Code:
$PathFile=$path.$Name
One last question if I can bother just once more.

Is there a way to set the display order? Perhaps by date it was saved? If there are duplicates or triplicates of an image (with different file names...) it can be rather difficult to find them because they are spread out through the list. How does the script call up the order?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Free Image Hosting / Script Sale 4n7hr4x Job Offers & Assistance 9 10-29-04 09:13 PM
View, edit, delete and add data to a database bigkid PHP 9 07-22-04 12:51 AM
Need Epinions-lite system in PHP & MYSQL wali001 Job Offers & Assistance 4 01-12-04 07:02 AM


All times are GMT -5. The time now is 08:00 PM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.