apple
Feb 24 2008, 02:03 AM
I am trying to do a simple thing. I want to display all the images of a directory on a single page with the checkbox next to each image, so that i can select multi images and i can delete selected images. Following few lines of code display the images of a directory.. i need help to put the check boxes with each image. and I dont understand how can i select multi images with check box and then delete them. I hope someone can help. thanks. CODE <?php
$path = "./"; $dir_handle = @opendir($path) or die("Unable to open folder");
while (false !== ($file = readdir($dir_handle))) {
if($file == "index.php") continue; if($file == ".") continue; if($file == "..") continue;
echo "<img src='$file' alt='$file'><br />";
} closedir($dir_handle);
?>
Comment/Reply (w/o sign-up)
apacheNewbie
Feb 24 2008, 09:19 AM
I would use file name as check box identifier. So first, we will add checkbox in your code CODE <?php
$path = "./"; $dir_handle = @opendir($path) or die("Unable to open folder");
while (false !== ($file = readdir($dir_handle))) {
if($file == "index.php") continue; if($file == ".") continue; if($file == "..") continue;
echo "<input type=CHECKBOX name=$file>"; echo "<img src='$file' alt='$file'><br />";
} closedir($dir_handle);
?> That is, now you have images with check box beside them. In order to delete the chosen images, you need to capture which checkbox is selected. This is the example of how to know which check box is checked (assuming, you are using POST method to submit the form using delete button): CODE <?php $path = "./"; $dir_handle = @opendir($path) or die("Unable to open folder");
//We list the name of the files again, since the name of the checkbox is the same with the name of the file while (false !== ($file = readdir($dir_handle))) {
if($file == "index.php") continue; if($file == ".") continue; if($file == "..") continue;
if(isset($_POST[$file])){ $checkbox = $_POST[$file]; if($checkbox == on) { //checkbox is selected //Delete the file if(!unlink($file)) die("Failed to delete file"); } } ?> Hopefully it helps 
Comment/Reply (w/o sign-up)
FeedBacker
Jun 26 2008, 09:22 AM
PHP display a column in vertical way
How To Display Images Of A Directory
HI, I'm new in php, if anyone can help me, I would really appreaciate it, my problem is, iwant to display a column or one column in vertical way like this: 1 2 3 4 5 6 Not the usual way like this: 1 2 3 4 5 6 Hoping for anyones reply. Many thanks in advance. -reply by marc
Comment/Reply (w/o sign-up)
optiplex
Jun 26 2008, 05:36 PM
This should help, not sure though : CODE <?php /* by optiplex */ $path = "./"; $dir_handle = @opendir($path) or die("Unable to open folder");
while (false !== ($file = readdir($dir_handle))) {
if(ereg("(.*)\.(jpg|bmp|jpeg|png|gif)", $file)){ echo "<img src='$file' alt='$file'><br />"; }
} closedir($dir_handle);
- optiplex
?>
Comment/Reply (w/o sign-up)
magiccode9
Jun 29 2008, 02:10 PM
This may be help a bit. CODE <?php
$file_ary = isset($_POST['rfile']) ? $_POST['rfile'] : array();
/** * At first visit, show the file list */ if (empty($file_ary)) { $image_path = dirname(__FILE__) . '/images'; $dir_handle = null; if (!($dir_handle = opendir($image_path))) { //trigger_error('error, path not found'); return; } $html = '<html><form method="post">'; $file = readdir($dir_handle); while ($file) { $html .= "{$file}<input type=\"checkbox\" name=\"rfile[]\" value=\"{$file}\" /><br />\r\n"; $file = readdir($dir_handle); } closedir($dir_handle); $html .= '<input type="submit" name="submit" value="Submit" />'; $html .= "</form></html>"; echo $html; }
/** * Now, we have list, display it or do anything you need to .. */ if (!empty($file_ary)) { echo '<pre>'; print_r($file_ary); echo '</pre>'; }
?> You may also check out this svn repository for updates when available https://opensvn.csie.org/freescript
Comment/Reply (w/o sign-up)
(G)Wolly
Sep 14 2009, 08:37 PM
create a database with images
How To Display Images Of A Directory
I would like help to create a database with images or link to images in a directory with title of the image and assigning a link to that image. Please
-reply by Wolly
Comment/Reply (w/o sign-up)
Similar Topics
Keywords : display, images, directory
- Securing Upload Directory
proper way to do it? (6)
Php Ftp Upload Form
Adding User Directory to PHP Upload Form - Help (1) Alright I am trying to have a PHP FTP Upload Form that allows the user to create the directory
folder for where they want to upload there files to. example: Main Directory: vainsoft.com There
directory: vainsoft.com/modeling or vainsoft.com/photography But I dont want them to be able to
upload things into the main directory, only sub-directories, is that possible with this coding that
I have: //uses $_FILES global array //see manual for older PHP version info //This function
will be used to get the extension from the filename function get_extension($file,$length....
Unofficial Trap17 Hosted Members Directory
(13) This is the Trap17 edition of the Hosted Members Directory. A script initially written by me for the
Astahost forums. The script has gone through many a changes and is currently in version 4 which
includes the following features:- > Listing of hosted members. > Listing of the websites of the
hosted members. > Validation of the websites (whether the site is suspended, working or not not
working, etc) > Save/Load result to/from database. > Multithreaded for faster operation. > Status
messages, images and progress bar to keep you informed of the process. Link to the Scrip....
How To Display The Latest Forum Post On Main Page
(4) Hey does anyone know how to display the latest forum post on the main page of a website? I'm new
to PHP and have no idea what to do. Thanks in advance!....
My Code Doesnt Resize Large Images, Please Help.
(2) Can someone please have a look at the following code, this uploads an image, and make it in 2 sizes,
one size is max. 600 x 800, uploads to images folder and second 120 x 120 and uploads to thumbs
folder. this script works fine, with normal size images, but if i try to upload large pics( for
example, an image with dimension 2432 x 3300, it shows blank page, and uploads the original image
without sizing to "image" folder, and doesnt make any small thumbnail... I hope u understand..
Please someone help me, i shall be so thankful. session_start(); header("Cache-contro....
Reading Files From Directory To Array, And Using $_get To Get Them
Simple way to manage lot's of files (2) Some user posted a similar problem i had when i tried to figure out how to update content on my
website in less work as possible. This is just part of the "big" plan i have for my site but it can
be helpfull to you guys if you like FlatFile. I hope that mod's don't mind me posting the
same code here and on their forums, couse if they do i'll delete it from their forums
/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> So
here's the situation. Let's say you have a folder called 'myfilesdirectory' on your
s....
Display The Current Date/time
With a simple PHP code (4) Use this code to display the current date and time. CODE $date = date('l dS \of F Y
h:i:s A'); echo "$date"; ?> "l" would display the current day of the week such as
Sunday. d displays the day of the month... such as 1 and S adds the appropriate suffix(st). /of
simply displays the word "of". F displays the current month with no abbreviations while Y displays
the four digit year(2007). "h" displays the current hour with leading zeros if necessary(Ex. 06 for
6 o'clock). "i" displays the minute of the hour with leading zeros if necessary. ....
Help Needed With Directory/file Listing Code Infinite Loop
Made an infinite loop but why is this so? (5) Hi all ive got a small and simple (for the moment atleast /unsure.gif"
style="vertical-align:middle" emoid=":unsure:" border="0" alt="unsure.gif" /> )file and directory
listing script in php as follows CODE $dir = "."; $num = 0; $file = scandir($dir); while($file
= scandir($dir)){ echo $file ; echo " "; $num = $num + 1; }; the concept is
simple enough, the directory to start with is the current one, so scan this directory and while we
have a result do a loop to echo the file/directories found, incriment the array number by one so we
get the....
Display Random File In A Directory
how to display a random file from a set directory. (9) hi, could someone please help me with this? I have some files in a directory and i want to know how
i can randomly display link/s to one or more of the files in my directory for download. But it must
not at any time display index.php which is also in the directory with the downloads. Thanks in
advance for any help given /unsure.gif" style="vertical-align:middle" emoid=":unsure:" border="0"
alt="unsure.gif" />....
Changin My Phpnuke Directory...please Help
(13) ok i wus fantastico to install my nuke...it asked me to give it a name for its directory so ive put
down "nuke" so to get to my site ud have to go to www.boaw.trap17.com/"nuke" but now i want to
change nuke into something else more related to the site...i was wondering if any1 can tell me the
best way to do that...thanks....
Display MySQL results in a Table
question (8) hi all i know php and my sql i want to know how can show mysql result in this tabel for example :
CODE 1 8 2 9
3 10 4 11 5 12
6 13 7 14 this table
show result in 2 columns . Is it imposible to show result in this tabale with 1 query ? Just paste
query here thanks all ....
Displaying Files Of A Directory
(2) I want to display the contents of a directory.. i have the following code.. It gives the output in
one column only... like file1 file2 file3 file4 . . . . . Since there are lot of files so this
column gets very long..i want to display the x number of files in each column.. like if there are 22
files.. then file 1 file 11 file 21 file 2 . file 22 file 3 .. . . . file 10
file 20 This was just an example..I know it can be done by using but i dont know how to do it
with loop. Please help me. QUOTE $dir = './'; $handle = opendir($....
How To List Files In A Directory + Subdirectory And Then Use Them.
(8) So lets say i have folders called friends and work in a folder called pics. how would i make a
function that lists the files in those folderscalled images kinda like this: CODE
$directory = "./" function listfiles($directory) { //here should go the script to list the files in
those directories. so that i can continue to work with them. like for example if there were images
it would list all the images and i could write a script to make a thumb of them and then save it
into a thumb folder(not asking for all of that). but how would i make it list it. // basic....
Directory Files Displaying
(5) I have many files in a directory..I want to create a page , like A B C D E F ..... when some one
click on A , it should display all the files starting from letter A , and when clicks on B , it
should show all the files in that directory starting from B , and so on... I have no idea how to
display the files of the directory iin that way. Kindly assist me......
How To Sort Files Of A Directory using Php
(12) The following code displays the files of folder...but they are displaced by the order of adding... i
want to sord the files / folders alphabetically and sord by accending order and by decending
order.. can some one help me. $path = ""; $dir_handle = @opendir($path) or die("Unable to open
$path"); echo "Directory Listing of $path "; while($file = readdir($dir_handle)) {
if(is_dir($file)) { continue; } else if($file != '.' && $file !=
'..') { echo " $file "; } } //closing the directory
closedir($dir....
How I Can Display Forum Topic On Main Website ?
(4) Suppose i have a website.. domain.com , and have phpbb forums on domain.com/forums.. And i want to
display the new topics written in the forum on the main page of website...how i can do that.. ? for
example ,I want to display this topic `? "domain.com/forums/viewtopic.php?t=16" how can i do that ?....
<textarea> Tag Is Not Accepting Php Variable
for display, although <Input> tag does accept it (2) I have a single page template which has a Form on it. Logic is to check for a valid Querystring and
place the variables accepted from a form back into the form and re-display this form with error or
acceptance messages. I'm sure everyone here has done this a million times. The Form accepts
data from a user for First name, Last name, email address, and message-body named
'note_wide' then re-displays the values into the Form, but for some reason, I can't get
the value to display into a Textarea. Sample of the php code is as follows: first the good one:....
Can You Add Images Into A Mysql Database?
Using Php? (23) I'm learning php in class right now, but I'm still not that good at it, what I'm
wondering is when I write the php so that it can connect with a database, can I at the same time
have it that it is able to display back images that I choose. Like, I want a search feature, where
you can search for a keyword, and it will bring back a list of all the possible entries with that
keyword, but each of these entries will have a photo associated with it. Now, do I put these image
files directly into the database, or do I write the code to link them from my files to th....
Help With Removing Files And Folders
removing all files from a directory (4) Is there a function or a group of functions which I can use to delete all the files an folders in a
directory? I've tried rmdir() but it complains that it can't remove it because there are
files/folders in it. ....
How To Create Images?
(3) How can i create images (using php) of 128x128 by giving some types of background... and users can
write text on the background... /blink.gif' border='0' style='vertical-align:middle'
alt='blink.gif' /> QUOTE you can take example from the followinbg site:
http://zedge.no/?side=navnelogo ....
Directory Function
- I need some help (1) Hey, I'm really in a jam. Here's whats happening, I have to post over 350 streaming WMA
files on a server. But it would be nice to not have to script it out in HTML. And I know that in PHP
you can set a directory or folder and PHP will place all the files out there. Would somone show me a
way to do that? and please note where I must insert filenames, folder, ect.... So, I have tons of
files that I need to have on the page, but scrpiting it takes long. Heres the page I'm working
on: http://www.cbf-wa.org/sermons.php thanx so much....
Securing Images
(2) Just wondering if anyone's worked with securing images to avoid direct linking than just by
obscuring the URL or using a .htaccess file. I briefly looked through the documentation and source
for gallery and it looks like the images are stored under the web root, so anyone with a direct link
can browse the images regardless of user privileges. I was thinking one way of doing this would be
too store the images above the webroot directory so that visitor's can't navigate to them
and having a php script that can read the image dir output the images by sending th....
Including Php-made Images In A Page?
(5) Say you have this script that makes an image, and you want to include it in another page. Would you
just use ? I'd test it right now, but all my PHP image stuff is on my school's server,
which is currently down.....
Script: Phpbb Mod, Total Users Registered
Display the total users anywhere on your site. (1) This is for phpBB V2+ It displays the total number of registered users anywhere you want. This file
is called: phpbb-totalusers.php CODE /** * ©2005 Craig lloyd. All rights reserved. * * Mod
Title: Total Registered Users * Author: Craig Lloyd * Description: Shows total number of
registered users * Release: v1.2, 10th May 2005 *** * Demo:
http://www.toxicsims.co.uk/ (stats box) * Installation Level: Easy * Installation Time: 1
minute * Files To Edit: This one * Included Files: phpbb-totalusers.php *** *
Installation Notes: * ....
Vote Script Help
images as a result? (1) I made a vote poll script, and it work fine with results in numers or %, but i want to show images
as a result. Is that possible? For example like voting poll in this forum. I tried something but
that couldnt work. Someone?....
Getting List Of Directories And Files Using Php
PHP Function for Directory and File List (6) is there a php function that lists the content of some folder.... example: /New folder new.txt
left.gif download.zip dc.exe ....so is there..? /rolleyes.gif' border='0'
style='vertical-align:middle' alt='rolleyes.gif' /> ....
Refreshing Images
(1) I've got a script that generates a graph by creating it as a .png file (I can't output the
image directly to the browser because of the way I need to generate the data). This all works ok
however, in order to keep the data managable I've set a limit so that it only displays 12 months
data at a time. The problem I have is that when I click on the next button to display the next set
of data, the graph remains the same until you refresh the browser. I've tried using unlink() to
delete the image file forcing the script to re-generate it when the script is r....
I Want A Php Code To Display The Most Popular...
(6) I want a PHP code to display the most popular clicks/links on certain pages. Can anyone help?....
Looking for display, images, directory
|
Searching Video's for display, images, directory
See Also,
|
advertisement
|
|