Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 





Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > Design Forum > Web Design & Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read

Web Design & Programming Discussion of web design, and server-side & client-side scripting

Reply
 
Thread Tools
Old 09-29-2008, 05:28 AM   #1 (permalink)
Registered User
 
Join Date: Sep 2008
Posts: 4
OS: Ubuntu HardyHeron / XP SP3


EEK! Webpage that automatically adds new filenames

Hi all

First post so here goes...been an avid reader for a while but the time has come.....

I am trying to set up a simple intranet site for my work and would like a bit of help with something which will make my life MUCH easier in the future.

The intranet site will only be used within my department to access help docs, .pdf/.doc etc. At the moment there are 200+ files in different folders and this will increase in the future. What I would like to have is a script or similar that will add the filename as a link in to the intranet webpage where the file is placed.

So for instance, I add a new pdf document called 'New User Setup.pdf' to a folder called 'User Setup' within the web folders and it would automatically (somehow.....using a periodically run script or db!!) create a link to that file on the user_setup.html/.php/.asp page.

At the moment I have not decided on the format i.e. php etc so open to suggestions. The simplar the better, however what I want may not be that simple!!

I have dealt with php/html & asp previously, also MySQL & M$ SQL.

Any ideas would be great....well, apart from "add all in manually including future ones" hehe

Thanks in advance.
cc_uk is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 09-29-2008, 05:39 AM   #2 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
Join Date: Jul 2007
Location: Northampton, UK
Posts: 1,090
OS: Win Vista Home Premium & Ubuntu Hardy(8.04)


Re: Webpage that automatically adds new filenames

Hey, this would be easy to do using PHP, rather than updating the list automatically you could get a list of all the files under the directory when the user requests the page...

e.g. have a listFiles.php file(or whatever name) and load it as the main page/a page when the user logs in... useful functions for this would be:

glob() - http://www.w3schools.com/PHP/func_filesystem_glob.asp
is_dir() - http://www.w3schools.com/PHP/func_filesystem_is_dir.asp
is_file() - http://www.w3schools.com/PHP/func_fi...em_is_file.asp

Using these three functions you could list the files in a certain directory when the page loads(hence no need to update a list).

Cheers,
Jamey
__________________

Help fight cancer. < I just started =]
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 09-29-2008, 05:40 AM   #3 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
Join Date: Jul 2007
Location: Northampton, UK
Posts: 1,090
OS: Win Vista Home Premium & Ubuntu Hardy(8.04)


Re: Webpage that automatically adds new filenames

oh, p.s. i could try writing some basic code for you in php if you'd like but as long as you have basic experience of PHP this should be fine.
__________________

Help fight cancer. < I just started =]
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 09-29-2008, 05:48 AM   #4 (permalink)
Registered User
 
Join Date: Sep 2008
Posts: 4
OS: Ubuntu HardyHeron / XP SP3


Re: Webpage that automatically adds new filenames

Thank you for the quick reply.

My php is not great!! Had a look at the links you have added and can't understand how it would create the links to the files. I understand that its pulling the list but not the linking.

A bit of coding would be a bloody great help if that's OK?
cc_uk is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 09-29-2008, 06:12 AM   #5 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
Join Date: Jul 2007
Location: Northampton, UK
Posts: 1,090
OS: Win Vista Home Premium & Ubuntu Hardy(8.04)


Re: Webpage that automatically adds new filenames

Okay, if i were doing this i'd do something like:

PHP Code:
<?

//get a list of all the files in the current directory(should list directories too[because theres no "."] 
$files glob("*");

//for each of the files(and hopefully folders[but i don't know])
foreach($files as $file){
   
//output it as the filename as a link
   //echo '<a href="' . $file . '">' . $file . '</a><br />';
   //or the above using double quotes(to avoid having all them dots):
   
echo "<a href='$file'>$file</a><br>\n";
   
}

?>
The above should list all the files in the directory that the .php file is in(though i haven't tested it so you'd have to try it out yourself)...

Cheers,
Jamey =]
__________________

Help fight cancer. < I just started =]
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 09-29-2008, 06:17 AM   #6 (permalink)
Registered User
 
Join Date: Sep 2008
Posts: 4
OS: Ubuntu HardyHeron / XP SP3


Re: Webpage that automatically adds new filenames

Nice one!!

Thank you very much!

I will try it later and let you know.

Again thanks a lot
cc_uk is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 09-29-2008, 08:57 AM   #7 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
Join Date: Jul 2007
Location: Northampton, UK
Posts: 1,090
OS: Win Vista Home Premium & Ubuntu Hardy(8.04)


Re: Webpage that automatically adds new filenames

I gave it a try on my own testing server and it works as i'd expected... =] Glad to be of help.

Cheers,
Jamey
__________________

Help fight cancer. < I just started =]
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 09-30-2008, 12:48 PM   #8 (permalink)
Registered User
 
Join Date: Sep 2008
Posts: 4
OS: Ubuntu HardyHeron / XP SP3


Re: Webpage that automatically adds new filenames

Hi

Thanks for the code....worked as you said...again thanks!!

Is there any way of getting the code to put the produced files in alphabetical order?

Also, can you steer me in the direction of how to tidy it up a bit, I would like to wrap a font around it and also a link colour but when I do it on either side of the code it messes up!!

Cheers!!
cc_uk is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 09-30-2008, 04:08 PM   #9 (permalink)
Design Team Member
 
dm01's Avatar
 
Join Date: Oct 2006
Location: Richmond, B.C.; Canada
Posts: 666
OS: Windows XP [Version 5.1.2600] SP3 | Ubuntu Hardy Heron


Re: Webpage that automatically adds new filenames

You could use CSS to efficiently and elegantly avoid that problem.

<html>
<head>
<style type="text/css">
a .file {color: "hexadecimal_value_of_colour"; font-family: "font"}
*/other CSS data*/
</style>
</head>
</body>
<!--data-->
echo "<a class="file" href='$file'>$file</a><br>\n";
</body>
</html>


"hexadecimal_value_of_colour": the hexadecimal value of the colour you have chosen. Each colour displayable by the browser has been assigned a particular alpha-numeric hexidecimal value, based on the hue, shade, and brightness of the colour. For example, the red I used to highlight the "class=file" is #ff0000. For more information on hexadecimal colour values, please read http://www.w3schools.com/Html/html_colors.asp.

Best of luck!
__________________


Validate your Markup
Validate your CSS
Free multi-purpose text and source code editor
dm01 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 09-30-2008, 05:05 PM   #10 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
Join Date: Jul 2007
Location: Northampton, UK
Posts: 1,090
OS: Win Vista Home Premium & Ubuntu Hardy(8.04)


Re: Webpage that automatically adds new filenames

dm01 covored the font thing... that would work great... as for sorting you could use an array sorting function in the PHP part of the code:

(to build upon my last code:)
PHP Code:
<?

//get a list of all the files in the current directory(should list directories too[because theres no "."]  
$files glob("*");

//sort the array alpabetically
sort($filesSORT_STRING);

//for each of the files(and hopefully folders[but i don't know])
foreach($files as $file){
   
//output it as the filename as a link
   //echo '<a href="' . $file . '">' . $file . '</a><br />';
   //or the above using double quotes(to avoid having all them dots):
   
echo "<a href='$file'>$file</a><br>\n";
   
}

?>

That should work(i think)...

Cheers,
Jamey
__________________

Help fight cancer. < I just started =]
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Reply


Thread Tools

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -7. The time now is 04:44 PM.



Copyright 2001 - 2008, Tech Support Forum

Search Engine Friendly URLs by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82