473,516 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Select a Item from a tree

1 New Member
Hi everyone,

how can i select an item from a directory and export the full name of it (for example test.txt) to an variable

the code on the dir list that i have is:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $show_path = 1;   # Show local path.
  3. $show_dotdirs = 1;   # Show '.' and '..'.
  4.  
  5. $path = substr($_SERVER['SCRIPT_FILENAME'], 0,
  6.     strrpos($_SERVER['SCRIPT_FILENAME'], '/') + 1);
  7. ?>
  8. <html>
  9.   <head>
  10.     <title>DIR</title>
  11.     <style type="text/css">
  12.       body {
  13.         font-family: Verdana, Arial, sans-serif;
  14.         margin: 40px;
  15.         text-align: center;
  16.       }
  17.  
  18.       body,
  19.       th,
  20.       td {
  21.         background-color: #ffffff;
  22.       }
  23.  
  24.       a:link {
  25.         color: #666666;
  26.         text-decoration: underline;
  27.       }
  28.       a:visited {
  29.         color: #444444;
  30.         text-decoration: underline;
  31.       }
  32.       a:hover {
  33.         color: #666666;
  34.         text-decoration: none;
  35.       }
  36.       a:active {
  37.         color: #660000;
  38.         text-decoration: none;
  39.       }
  40.  
  41.       table {
  42.         background-color: #222222;
  43.         border: #cccccc solid 1px;
  44.         border-spacing: 1px;
  45.         width: 480px;
  46.       }
  47.       th {
  48.         background-color: #4466aa;
  49.         color: #ffffff;
  50.         font-size: 11pt;
  51.         font-weight: bold;
  52.         text-align: left;
  53.         padding: 2px;
  54.       }
  55.       td {
  56.         background-color: #eeeeee;
  57.         color: #666666;
  58.         font-size: 9pt;
  59.         font-weight: normal;
  60.         padding: 6px;
  61.       }
  62.     </style>
  63.   </head>
  64.   <body>
  65.  
  66.     <table cellspacing="1">
  67.       <tr>
  68.         <th><?php if ($show_path == 1) { echo $path; } else { echo 'content of this directory'; } ?></th>
  69.       </tr>
  70.       <tr>
  71.         <td>
  72. <?php
  73. $dirs = array();
  74. $files = array();
  75.  
  76. $dir = dir($path);
  77. while ($entry = $dir->read()) {
  78.     if (($entry != '.') and (substr($entry, -4) != '.php')) {
  79.         if (is_dir($entry)) {
  80.             if (($entry != '..') or $show_dotdirs){
  81.                 $dirs[] = $entry;
  82.             }
  83.         } else {
  84.             $files[] = $entry;
  85.         }
  86.     }
  87. }
  88. $dir->close();
  89.  
  90. sort($dirs);
  91. foreach ($dirs as $dir) {
  92.     printf('<strong>&lt;</strong> <a href="%s">%s</a> <strong>&gt;</strong><br />' . "\n", $dir, $dir);
  93. }
  94.  
  95. sort($files);
  96. foreach ($files as $file) {
  97.     printf('<a href="%s">%s<br />' . "\n", $file, $file);
  98. }
  99. ?>
  100.         </td>
  101.       </tr>
  102.     </table>
  103. <button type="button" onClick="window.location.href='../../main_login.php'";>Retroceder</button>
  104.   </body>
  105. </html>
  106.  
Feb 28 '11 #1
1 1540
JKing
1,206 Recognized Expert Top Contributor
Have a look at the realpath() function in PHP.
Feb 28 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3096
by: K. Lobe | last post by:
list box based on a POST method to the same page. frm.cmbList.Value=Request.Form("cmbList") doesn't work. When the page loads, it reloads the <SELECT>, so not sure how to get the list to go to the item. Any ideas? many thnx,
1
3327
by: kerravon.geo | last post by:
I have a listbox whose rowsource is set to a memo field containing a semi-colon delimited value list. Upon initial opening of the form, I can't select an item from the list. However, if I add a new item to the list I can select any of the items in the list. Any ideas how I can fix this? Thanks!
0
1899
by: Marta Pia | last post by:
Hello, I have a ListView control with CheckBox = true. What I'd like to do is tick all the check boxes when the items are selected. I've tried to put this on the ListView_SelectIndexChanged event, as below: private void lstResultDetail_SelectedIndexChanged(object sender, System.EventArgs e) { ListView.SelectedListViewItemCollection...
1
1839
by: Giang Pham | last post by:
Dear all, When I add one row in my listview (type : details), I want to set it as selected. How could I do this ? Thank you a lot.
7
4203
by: localhost | last post by:
A DataGrid with shows a label in one of the columns when in view mode. When in edit mode, I want to show a dropdown, and have the default selection set to what the textbox used to be. Right now the first item in the dropdown is always displayed. Template Code: <asp:TemplateColumn HeaderText="DropDown"> <ItemTemplate> <asp:Label...
5
37254
by: Richard Bond | last post by:
I'm having a lot of trouble programatically selecting a listview item. How do you do this? These didn't work for me in the context of the sub below (that's trying to move up an Item in the listview) MeasView.Items(ItemIndex - 1).Selected = True MeasView.Items(ItemIndex - 1).Focused = True I would really appreciate some help.
5
17784
by: mabond | last post by:
Hi My project has a form, two list boxes (lstArchive and lstSchedule) and two buttons (btnSendArchive and btnSendSchedule) Each list box represents the content of a directory. The command buttons move the selected item out of one directory and into the other and refreshes the list boxes to reflect the change in directory contents I now...
4
3640
by: deepee | last post by:
I have a drop down box in HTML using SELECT and OPTION tags: <select title="Choose a number" onchange="obscure()" name="Digit1" ID="Digit1"> <OPTION VALUE="">&nbsp;</OPTION> <OPTION VALUE="0">&nbsp;0</OPTION> <OPTION VALUE="1">&nbsp;1</OPTION> <OPTION VALUE="2">&nbsp;2</OPTION> <OPTION VALUE="3">&nbsp;3</OPTION> </select>
2
1843
by: JamesW | last post by:
Hi there. Vstudio 2003, IE 6.0 I have an asp connected to an Access database. A DropDownList on the page shows names from the Db. When the user selects a name from the DropDownList I want the selected name to appear in a text box on the page.
3
10563
by: Lohboy | last post by:
Using ASP.NET and IE7. (Sorry if I am posting in the wrong forum but my problem seemed to be more related to the JavaScript side than the ASP.NET side.) I have two DropDownList controls the second of which resides within an UpdatePanel control which responds to a change in the first DropDownList. I also have a hidden button nested inside the...
0
7276
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7581
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7142
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7548
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5110
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4773
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3259
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
488
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.