/    Sign up×
Community /Pin to ProfileBookmark

FTP login script

im trying to make a login page for my ftp server that uses the ftp browser in internet explorer. all i need it to do is have 2 text boxes(one for user name and one for password) and a go button, the format for the ftp login link is
[url]ftp://[/url][login]:[pw]@[site]:[port]
the script needs to fill in the login and pw fields. if you can help please respond or email me. or if you know another way to do this, anything would be helpfull

to post a comment
JavaScript

17 Comments(s)

Copy linkTweet thisAlerts:
@AdamGundrySep 07.2003 — A quick Google search turned up this (should be fairly easy to modify to one site): http://javascript.internet.com/navigation/ftp-server-login.html

Adam
Copy linkTweet thisAlerts:
@GavinPearceSep 07.2003 — There you go, just incase. You could aslo have done this with a hidden form field but decided might as well put it in the JavaScript.

<i>
</i>
&lt;!-- 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 --&gt;

&lt;!-- STEP ONE: Paste this code into the HEAD of your HTML document --&gt;

&lt;HEAD&gt;

&lt;SCRIPT LANGUAGE="JavaScript"&gt;
&lt;!-- Original: Reinout Verkerk --&gt;
&lt;!-- This script and many more are available free online at --&gt;
&lt;!-- The JavaScript Source!! <a href="http://javascript.internet.com">http://javascript.internet.com</a> --&gt;

&lt;!-- Begin
function Login(form) {
// NOTE: the <a href="ftp://">ftp://</a> part is automatically added by the script, you do not need it below.

var server = "server-ftp-address.com";

// Do not edit below this point
var username = form.username.value;
var password = form.password.value;

if (username &amp;&amp; password &amp;&amp; server) {
var ftpsite = "ftp://" + username + ":" + password + "@" + server;
window.location = ftpsite;
}
else {
alert("Please enter your username, password, and FTP server's address.");
}
}
// End --&gt;
&lt;/script&gt;
&lt;/HEAD&gt;

&lt;!-- STEP TWO: Copy this code into the BODY of your HTML document --&gt;

&lt;BODY&gt;

&lt;center&gt;
&lt;form name=login&gt;
&lt;input type=hidden name=server value="ftp://yoursite.com" size=14&gt;
&lt;table width=250 border=0 cellpadding=3&gt;
&lt;tr&gt;
&lt;td colspan=2 align=center&gt;&lt;b&gt;&lt;h2&gt;Logon to FTP Server!&lt;/h2&gt;&lt;/b&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Username:&lt;/td&gt;
&lt;td&gt;&lt;input type=text name=username size=20&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Password:&lt;/td&gt;
&lt;td&gt;&lt;input type=password name=password size=20&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=2 align=center&gt;
&lt;input type=button value="Login!" onClick="Login(this.form)"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;
&lt;/center&gt;

&lt;!-- Terms say you have to leave ads in so.. --&gt;
&lt;p&gt;&lt;center&gt;
&lt;font face="arial, helvetica" size="-2"&gt;Free JavaScripts provided&lt;br&gt;
by &lt;a href="http://javascriptsource.com"&gt;The JavaScript Source&lt;/a&gt;&lt;/font&gt;
&lt;/center&gt;&lt;p&gt;

&lt;!-- Script Size: 1.53 KB --&gt;

Copy linkTweet thisAlerts:
@DagamantauthorSep 08.2003 — that was perfect. exactly what i was looking for, thank you
Copy linkTweet thisAlerts:
@GavinPearceSep 08.2003 — Your welcome ?
Copy linkTweet thisAlerts:
@-_NTL_-May 20.2004 — If you have multiple users then the script doesent work becasue it takes you to the root of the FTP site then just leaves you hanging. Is there something I am doing wrong here???
Copy linkTweet thisAlerts:
@-_NTL_-May 20.2004 — people please read this
Copy linkTweet thisAlerts:
@GavinPearceMay 20.2004 — You can't really set what directory it open into with JavaScript.

From your description you are either after something more powerful than JavaScript or you need to modify the server settings a bit.

What excatly are you trying to achieve?
Copy linkTweet thisAlerts:
@-_NTL_-May 20.2004 — Well I am trying to get it to get the username and password to link to the [email protected]">ftp://unsername:[email protected] When I try it i just goes to the root folder instead of the fold I am trying to get it to. If you know an FTP site try it and you will see what i mean. But I have adjusted my FTP server to work with the simple address [email protected]">ftp://unsername:[email protected] adn i tested it from internet explorer and it works just fine. But when using the script it just goes directly to the ROOT site and not hte actualy directory I weant it to. I am thinking you may need to see it for yourself. But I am in the porcess of writing a different script that may do what I want. It would save me quite a few hours if I can just hve this one do what I want though.


Thanks
Copy linkTweet thisAlerts:
@-_NTL_-May 20.2004 — Sorry about the terrible spelling I am just doing a million things at once.
Copy linkTweet thisAlerts:
@-_NTL_-May 20.2004 — if you use an <a href "ftp://username:[email protected]:> then it will work...is there a was to make a <A href> statement work with an if then statement?
Copy linkTweet thisAlerts:
@GavinPearceMay 21.2004 — So your saying you login by typing in the URL into IE and it takes you to the folder its meant to but if you login via that script it doesn't take you to the folder your meant to?

it should be excatly the same, all the script is doing is redirecting you to the page with the varibles in, so it's still using IE, its not actually logining you in to the server itself.
Copy linkTweet thisAlerts:
@mimimuAug 01.2005 — hi NTL,

I have the exact same problem you had, the javascript works, but it go to the root folder first, with link to a list of folders. And once you click on the folder then it take you to the FTP interface. Have you ever figure this out? Really need to make this thing work.... ?

or does any one know other ways to do this? other scripting language etc?

thanks a lot, and please reply
Copy linkTweet thisAlerts:
@DagamantauthorMay 19.2006 — iv been using the script supplied by gavinet for a long time now and i havnt had this problem. it sounds like your users are all set up to start in the root directory and youve just created folders for them. or their all members of a group that has root access. if they are part of a group you need to take away any group permisions that they have so the ftp server defaults on their user permissions. that would send them to their home directories when they log in. also, if you have less that 50 users you probly have no need for groups.
Copy linkTweet thisAlerts:
@rgagli1Nov 16.2007 — Does this work with a mac and firefox? I can't get it to work.
Copy linkTweet thisAlerts:
@GavinPearceNov 19.2007 — This is one from the grave I'll give you that!

All this script does is provide a simple redirection to an ftp:// address.

If you can login using your version of Mac/Firefox via a ftp:// style address, then the script should work fine.

However a lot of browsers these days are not setup to understand ftp:// as a default, so might require changing some browser settings. Not an expert on macs I have to admit ... Anyone else?
Copy linkTweet thisAlerts:
@c____Feb 17.2008 — www.rmt-corp.com

this is my site. i need to code the logon box to the right. we have hosting from earthlink. i want our customers to be able to type in their logon and password and hit the login button. the ftp path should be the same all the time and therefore can be hidden. i assume. i am not a web developer but more of a hack. any help will be greatly appreciated and can XXXXXXXi am getting fairly desperate. if this double posts i apologize thank!

edited by WebJoel: stating or suggesting compen$ation for any help violates TOS. Help here if FREE, don't suggest payment or hires. You may via PMs do whatever you wish.

This is educational, not for hires. ?
Copy linkTweet thisAlerts:
@appatightNov 27.2008 — Well I am trying to get it to get the username and password to link to the [email protected]">ftp://unsername:[email protected] When I try it i just goes to the root folder instead of the fold I am trying to get it to. If you know an FTP site try it and you will see what i mean. But I have adjusted my FTP server to work with the simple address [email protected]">ftp://unsername:[email protected] adn i tested it from internet explorer and it works just fine. But when using the script it just goes directly to the ROOT site and not hte actualy directory I weant it to. I am thinking you may need to see it for yourself. But I am in the porcess of writing a different script that may do what I want. It would save me quite a few hours if I can just hve this one do what I want though.


Thanks[/QUOTE]



Well that can be accomplished by server settings. I'm not sure what settings are available to you on your ftp server. I have my own ftp server and it is hosted on a UNIX box. I can go to /var/vsftpd/vsftpd.conf and I can vi the config file and set what directory will be each user's home directory on the server. If you are using a ftp server like from your ISP or some other hosting service then it may not have settings to change the directory for the users.

What ftp service are you using?
×

Success!

Help @Dagamant spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...