473,387 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 12615
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="JavaScript">
<!-- 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.value;
var password = form.password.value;
var server = form.server.value;
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
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. ...
4
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...
10
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...
13
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"...
7
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...
1
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...
1
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...
5
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...
1
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.