473,907 Members | 6,277 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to get file listing in current dir??

Is it possible to use javascript to get a list of files from the current
directory where the html page that contains the javascript is being called?
The reason is that I want to find all ".jpg" files in the current dir and
randomly display one. Right now I am manually putting each file name in an
array element, very hard to maintain...

Clayton
Jul 23 '05 #1
5 12641
On Mon, 28 Jun 2004 00:18:48 GMT, - CT - wrote:
Is it possible to use javascript to get a list of files from the current
directory where the html page that contains the javascript is being called?


No, not unless it is server-side script
(which, no, yours it most probably not).

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Jul 23 '05 #2

"Andrew Thompson" <Se********@www .invalid> ????
news:fp******** *************** *******@40tude. net...
On Mon, 28 Jun 2004 00:18:48 GMT, - CT - wrote:
Is it possible to use javascript to get a list of files from the current
directory where the html page that contains the javascript is being
called?
No, not unless it is server-side script
(which, no, yours it most probably not).


-Agree with the NO

www.vicdir.com
Jul 23 '05 #3
On Mon, 28 Jun 2004 00:18:48 GMT, - CT - wrote:
Is it possible to use javascript to get a list of files from the current
directory where the html page that contains the javascript is being called?
The reason is that I want to find all ".jpg" files in the current dir and
randomly display one. Right now I am manually putting each file name in an
array element, very hard to maintain...


I just saw your reply to my other post,
but thought I would reply to this one..

Now, generating HTML using a script is
generally frowned upon. It is better to
have a complete web page that you then
*manipulate* with JS, hiding parts of it
as required.

Having said that, there are situations
where the requirement to support non JS
browsers is not as great, and for *that*
I use my own CattleDog file finder to
make the list of files for me.

I never polished the UI nor specialized it
for the casual user, but you may find it
to be of some help.

You can find it here (part of the software suite)
<http://www.physci.org/install/download.jsp>

HTH

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Jul 23 '05 #4
On Mon, 28 Jun 2004 00:18:48 GMT, - CT - wrote:

Is it possible to use javascript to get a list of files from the current
directory where the html page that contains the javascript is being
called?


You have to modify this to bypass the login function.

<!-- TWO STEPS TO INSTALL FTP SERVER LOGIN:

1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->

<HEAD>

<SCRIPT LANGUAGE="JavaS cript">
<!-- Original: Reinout Verkerk -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function Login(form) {
var username = form.username.v alue;
var password = form.password.v alue;
var server = form.server.val ue;
if (username && password && server) {
var ftpsite = "ftp://" + username + ":" + password + "@" + server;
window.location = ftpsite;
}
else {
alert("Please enter your username, password, and FTP server's address.");
}
}
// End -->
</script>
</HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document -->

<BODY>

<center>
<form name=login>
<table width=250 border=1 cellpadding=3>
<tr>
<td colspan=2 align=center><b ><h2>Logon to FTP Server!</h2></b></td>
</tr>
<tr>
<td>Username: </td>
<td><input type=text name=username size=20></td>
</tr>
<tr>
<td>Password: </td>
<td><input type=password name=password size=20></td>
</tr>
<tr>
<td>Server:</td>
<td><tt>ftp://</tt><input type=text name=server size=14></td>
</tr>
<tr>
<td colspan=2 align=center>
<input type=button value="Login!" onClick="Login( this.form)"></td>
</tr>
</table>
</form>
</center>
<!-- Script Size: 1.53 KB -->
Jul 23 '05 #5
Electric Nachos wrote:
On Mon, 28 Jun 2004 00:18:48 GMT, - CT - wrote:
Is it possible to use javascript to get a list of files from the current
directory where the html page that contains the javascript is being
called?


You have to modify this to bypass the login function.
[...]
<!-- Script Size: 1.53 KB -->


That script does not only *not* solve the problem of the OP (the goal
was to retrieve the file list of the *current* directory to *access it
with scripting*) but also requires FTP access to the Web server, and it
is not Valid HTML. Besides, it raises a security issue as the "ftp:"
URL used, including the username and passwort, is stored in the history
of the current user. If a Web site is accessed in an Internet café
this way, it would most certainly mean a breach of security as the next
visitor can easily access the Webspace and possibly the whole account
of the previous one.

That script is 1.53 KB of utter nonsense.
PointedEars
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
5475
by: Dave Smithz | last post by:
Hi There, I have a PHP script that sends an email with attachment and works great when provided the path to the file to send. However this file needs to be on the same server as the script. I want to develop a webpage where people can send attachments that are stored on their local PC.
4
1706
by: Angelos | last post by:
Hello.. I am trying to make a filesystem management script. I want to display a list of files and directories and be able to delete them from this list.... I made a search on the net and there are loads of them but I am trying to do something much more simple. At the moment I can display everything within a folder but if I click on a directory it won't go into the directory, listing all contents ... it is just a link.
10
2478
by: Chris | last post by:
Hi, Not sure if this is the right forum, but hopefully someone can help me. I am creating something for our intranet and i want to list the files and folders of a directory, i found some code to do this. The only problem is that it lists the asp file used to for example if i go to: "http://myserver/listing.asp" In the file listing will be "listing.asp" amongst a lot of marketing documents.
13
13270
by: Hemant Sipahimalani | last post by:
The following piece of code is being used to export HTML to excel. HttpContext.Current.Response.ContentType = "application/vnd.ms-excel" HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=ABC.xls") HttpContext.Current.Response.Write(strHTML) HttpContext.Current.Response.End() However when the user tries to save it the Default File Type is Web Page(*.htm; *.html)
7
2426
by: vbsourcer | last post by:
Listing two fields -------------------------------------------------------------------------------- Hello all could anybody tell me how I would be able to list information from a database using Two Fields from the Database ? I have this code which will populate the listbox with exactly what I want by when the user clicks the listbox to view the customers information an error message returns "No Current Record" here's the code I am using...
1
2433
by: Reb | last post by:
Hi all, I have not successfully found a Javascript sample for getting next and previous links from a file... I figured that someone must have solved this problem already! ... here is what I'm trying to do. I have a multi-framed file, with navigation in a top bar. Within each content directory, I have a file called nav.txt that lists the files in order. I'd like my next and previous buttons to be able use the nav.txt file to determine...
1
3473
by: sandeepifw | last post by:
plz help I have a php variable $content on page menu.php now i wnt to use its value on page menu_items.js hear menu_items.js create a menubar.its contan both static and dynamic menu my lase menu as vander is dynamic now how can i use this variable on .js my js file look like
5
3493
by: jain236 | last post by:
HI every body, i am always getting the following error while parsing a directory . i am reading a directory by doing ls and trying to find out the name,type,size, mtime and mode of files from the directory my @valeu =@{$Files}; foreach my $file (parse_dir(\@valeu)) { @Files = $ftp->ls('-lR');
1
1961
by: =?Utf-8?B?RVFOaXNo?= | last post by:
Not sure if this is the spot to ask but I need some help with a script I hijacked and put to my own use in an .ASP page any ways I am using the FilesystemObjects to get a directory and file listing and generating a web page of that listing, but I need to filter out files with the SYSTEM tag, so it wont show files I dont want it to, Below is my full code for the ASP page, I have Commented where I need to change the listing structure, if...
0
10015
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11318
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11012
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10518
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7231
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5917
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6111
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4325
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3337
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.