Jump to content

browser based ftp login


mrudnick

Recommended Posts

Hello all,
First let me say that I don't really know PHP at all.
What I want to do is have an HTML page where users type in a username and password. After they click submit they are redirected to
"ftp://username:[email protected]" where they can download and upload files to their folder.
Each username will have a folder in the directory that has the same name as the username. `So if "Mark" logs in, I want him to see the contents of the "Mark" folder where he can upload and download files. I don't want him to have access to anything else.
As I know nothing, I did a lot of reading up and researching on how to do this (lots of great information on this site by the way) but the PHP code might still be way off.


Here is the code I have so far:
for the html login page:
<html>
<body>
<form name="form" method="post" action="ftp.php">
Username: <input name="username" type="text" size="30">
Password: <input name="password" type="password" size="30">
<input type="Submit" size="8" value="Submit"></p>
</form>
</body>
</html>

the code for the ftp.php page is :
<?php

$ftp_server = 'domain.com'; //domain being the future website domain
$ftp_username =$_POST['username'];
$ftp_password =$_POST['password'];
$location = 'ftp://$ftp_username:$ftp_password@$ftp_server';
header('Location: $location');

$ftp_connect_id = ftp_connect($ftp_server);
$ftp_login = ftp_login($ftp_connect_id, $ftp_username, $ftp_password);
if (! $ftp_connect_id || ! $ftp_login)
{
echo "Unable to connect to ".$ftp_server;
exit;
} else {
echo "Connected to host "<p>";
}
ftp_close($ftp_connect_id);
?>

right now, when i check it, I log on the html page and go the the php page where all it says is "Connected to host."
I don't see the "ftp://username:[email protected]" that I want to see.
Any help is greatly appreciated
Link to comment
https://forums.phpfreaks.com/topic/29978-browser-based-ftp-login/
Share on other sites

  • 2 months later...
I have the same question regarding the below topic.  I did not see any replies to this question.  I am trying to use a website to have clients login to the host ftp site.  My web template is made with Swish.  The below question is the only familiar topic I can find to get assistance with this.  Any help?

[quote author=mrudnick link=topic=117908.msg481346#msg481346 date=1165613019]
Hello all,
First let me say that I don't really know PHP at all.
What I want to do is have an HTML page where users type in a username and password. After they click submit they are redirected to
"ftp://username:[email protected]" where they can download and upload files to their folder.
Each username will have a folder in the directory that has the same name as the username. `So if "Mark" logs in, I want him to see the contents of the "Mark" folder where he can upload and download files. I don't want him to have access to anything else.
As I know nothing, I did a lot of reading up and researching on how to do this (lots of great information on this site by the way) but the PHP code might still be way off.


Here is the code I have so far:
for the html login page:
<html>
<body>
<form name="form" method="post" action="ftp.php">
Username: <input name="username" type="text" size="30">
Password: <input name="password" type="password" size="30">
<input type="Submit" size="8" value="Submit"></p>
</form>
</body>
</html>

the code for the ftp.php page is :
<?php

$ftp_server = 'domain.com'; //domain being the future website domain
$ftp_username =$_POST['username'];
$ftp_password =$_POST['password'];
$location = 'ftp://$ftp_username:$ftp_password@$ftp_server';
header('Location: $location');

$ftp_connect_id = ftp_connect($ftp_server);
$ftp_login = ftp_login($ftp_connect_id, $ftp_username, $ftp_password);
if (! $ftp_connect_id || ! $ftp_login)
{
echo "Unable to connect to ".$ftp_server;
exit;
} else {
echo "Connected to host "<p>";
}
ftp_close($ftp_connect_id);
?>

right now, when i check it, I log on the html page and go the the php page where all it says is "Connected to host."
I don't see the "ftp://username:[email protected]" that I want to see.
Any help is greatly appreciated
[/quote]
  • 3 weeks later...
Hold your horses! This may be much harder than you think. Simply connecting to the folder isn't enough. You would need to use a ftp program, or a simple one to upload and downlaod files. You would need to create restrictions, and be aware of "bad" files on your server - viruses. I would recommend finding a way to upload and download files through a free ftp program and try posting it on the site. After you got that working worry about connecting to the files. Because right now, there is no point connecting to the folder without FTP.

Good Luck! If you get this done it will be an accomplishment!
  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.