 |
|
| Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more. |
|
 |

04-14-2006, 11:20 PM
|
 |
Junior Member
|
|
Join Date: 04-14-06
Location: Boston
Posts: 18
|
|
|
FTP Login PHP Script from Website
Hi. I am looking to create a FTP login from my website.
It will have two fields, a username and pass.
My server/host connects from a broswer with 'ftp://specificuser@website.com' and locks the users into their directories.
The whole 'Username' would be 'specificuser@website.com'. That's fine.
1) The first problem is with the PHP script I found, I would have to to connect to a generic FTP address instead and this is not possible with the above scenario. I don't know how to modify the PHP code below.
2) Second problem. I'd like to take out the directory portion of the HTML. It's simple to remove but how does it relate to the PHP portion?
Can someone be kind enough to take a look at it?
Here is the HTML code referencing the ftp.php file:
HTML Code:
<form action="ftp.php/" method="POST">
<p>Username<input name="username">
<p>Password<input name="password" type="password">
<p><input name="login" type="submit" value="login">
</form>
Here is the PHP code:
PHP Code:
<?php
/*
*/
// quick "die" function
function funk_die($msg) {
if($msg=='normal') {
return "<html><body><a href=\"ftp.php\">back</a></body></html>";
}
}
// function to give dir listing stuff
function dir_funk () {
// cookie?
global $ftp;
// dir name
$dir=ftp_pwd($ftp);
// dir listing array
$dirlist=ftp_rawlist($ftp,$dir);
// print the directory listing
$funk = "<html><body><p>current directory: <b> $dir </b></p>";
$funk .= "<p><a href=\"ftp.php?&updir=$dir\">go up one level</a>
</p>";
$funk .= "<p>
<table cellspacing=0 cellpadding=2 border=1>
<tr><td><b>permissions</b></td><td><b>file/directory</b></td>
<td><b>download</b></td><td><b>delete</b></td>
<td><b>chmod</b></td><td><b>rename</b></td>
</tr>
";
while(list($i,$thingy)=each($dirlist)) {
$thingy=preg_replace("/\s+/", " ", $thingy);
if($i==0) {
echo "";
} else {
list($chmod,$thing,$owner,$group,$size,$month,$day,$time,$filename)=explode(" ",$thingy);
if(ereg("d",$chmod)) {
$funk .= "<tr><td>$chmod</td><td><a href=\"ftp.php?dir=$dir/$filename\">$filename</a></td>
<td>dir</td>
<td><a href=\"ftp.php?delete=dir&thingy=$dir/$filename\">delete</a></td>
<td><a href=\"ftp.php?chmod=1&thingy=$dir/$filename\">chmod</a></td>
<td><a href=\"ftp.php?rename=$dir/$filename\">rename</a></td>
</tr>";
} else {
$funk .= "<tr><td>$chmod</td><td>$filename</td>
<td><a href=\"ftp.php?dl=1&file=$dir/$filename\">d/l ($size)</a></td>
<td><a href=\"ftp.php?delete=file&thingy=$dir/$filename\">delete</a></td>
<td><a href=\"ftp.php?chmod=1&thingy=$dir/$filename\">chmod</a></td>
<td><a href=\"ftp.php?rename=$dir/$filename\">rename</a></td>
</tr>";
}
}
}
$funk .= "</table>
</p>";
$funk .= "<p>Create a new directory<br>
<form action=\"ftp.php\" method=\"POST\">
<input size=\"15\" name=\"name\">
<input type=\"hidden\" name=\"current_dir\" value=\"$dir\">
<input type=\"submit\" name=\"newdir\" value=\"create_dir\">
</form>
</p>";
$funk .= "<p>Upload a local file<br>
<form action=\"ftp.php\" method=\"POST\">
<input type=\"file\" name=\"localfile\"><br>
<input type=\"hidden\" name=\"current_dir\" value=\"$dir\">
<input type=\"submit\" name=\"upload\" value=\"upload_file\">
</form>
</p>";
$funk .= "</body></html>";
return $funk;
}
if(!$login) {
// print the login form
echo "<html><body><p><b>ftp login</b><hr></p>
<form action=\"ftp.php\" method=\"POST\">
<p>Your server (eg ftp.yoursite.com)<br> <input size=\"30\" name=\"server\"></p>
<p>Username <br> <input size=\"30\" name=\"username\"></p>
<p>Password <br> <input size=\"30\" name=\"password\"></p>
<p><input type=\"submit\" name=\"login\" value=\"login\"></p>
</form></body></html>";
} else {
// try to connect or die with an error
$ftp=ftp_connect($server) or die("invalid server");
// try to login or die with error
$conn=ftp_login($ftp,$username,$password) or die("login failed for some reason");
// set a cookie so the !$login form above is never displayed
setcookie("login","active");
// set goody cookies
setcookie("server",$server);
setcookie("username",$username);
setcookie("password",$password);
if($dir) {
ftp_chdir($ftp,$dir);
echo dir_funk();
} elseif($dl) {
if($get) {
if(!$local) {
die("please enter a value");
}
ftp_get($ftp, $local, $file, FTP_BINARY);
echo funk_die(normal);
} else {
echo "<html><body>";
echo "download file";
$size=ftp_size($ftp,$file);
$time=ftp_mdtm($ftp,$file);
$time=date("d M Y, H i",$time);
echo "<p><table cellspacing=0 cellpadding=2 border=1>
<tr><td><b>filename</b></td><td><b>size</b></td>
<td><b>date modified</b></td></tr>
<tr><td>$file</td><td>$size</td><td>$time</td></tr></table>";
echo "<form action=\"ftp.php\" method=\"POST\">
where to download the file to (/home/me/file.txt or c:/file.txt):<br>
<INPUT NAME=\"local\" size=\"40\">
<input type=\"hidden\" name=\"dl\" value=\"1\">
<input type=\"hidden\" name=\"file\" value=\"$file\"><br>
<INPUT TYPE=\"submit\" name=\"get\" VALUE=\"download file\">
</FORM>";
echo "</body></html>";
}
} elseif($rename) {
if($do) {
if(!$val) {
die("please enter a value");
}
ftp_rename($ftp, $rename, $val);
echo funk_die(normal);
} else {
echo "<html><body>
rename this file: $rename
<p>
<form action=\"ftp.php\" method=\"POST\">
Rename to: <input size=\"50\" name=\"val\" value=\"$rename\"><br>
<input type=\"hidden\" name=\"rename\" value=\"$rename\">
<input type=\"submit\" name=\"do\" value=\"rename\">
</form>
</body></html>";
}
} elseif($chmod) {
if($do) {
if(!$val) {
die("please enter a value");
}
$cmd="CHMOD $val $file";
ftp_site($ftp, $cmd);
echo funk_die(normal);
} else {
echo "<html><body>
chmod this file: $thingy
<p>
<form action=\"ftp.php\" method=\"POST\">
<input size=\"4\" name=\"val\" maxlength=\"4\"> CHMOD value<br>
<input type=\"hidden\" name=\"file\" value=\"$thingy\">
<input type=\"hidden\" name=\"chmod\" value=\"1\">
<input type=\"submit\" name=\"do\" value=\"chmod\">
</form>
</body></html>";
}
} elseif($delete) {
if($delete=='file') {
ftp_delete($ftp, $thingy);
} elseif($delete=='dir') {
ftp_rmdir($ftp, $thingy);
}
echo funk_die(normal);
} elseif($upload) {
if(!$localfile) { die("please enter a file"); }
$file = substr( strrchr( $localfile, "/" ), 1 );
$put_thingy = $current_dir . "/" . $file;
ftp_put($ftp, $put_thingy, $localfile, FTP_BINARY);
echo funk_die(normal);
} elseif($newdir) {
if(!$name) { die("please enter a name"); }
$newdir = $current_dir . "/" . $name;
ftp_mkdir($ftp,$newdir);
echo funk_die(normal);
} elseif($updir) {
$newdir = str_replace( substr( strrchr( $updir, "/" ), 1 ) , "", $updir);
ftp_chdir($ftp,$newdir);
echo dir_funk();
} else {
echo dir_funk();
}
}
?>
Could someone show me proper working code please?
|

04-15-2006, 12:34 AM
|
 |
Contributing Member
|
|
Join Date: 04-07-06
Location: Manchester, NH
Posts: 722
|
|
Since you don't want the directory code you'd do a lot better using a simpler script than trying to parse out the code you don't want in this one.
Like this, only as modified below.
Note that it's not using that user@yourwebsite.com syntax, because the ftp server should be smart enough to place the user into the proper directory based on the login credentials. I don't think it's the syntax that matters, it's the user's role that determines where he lands.
http://www.w3schools.com/php/func_ftp_pwd.asp
Simplified:
<form action="ftp.php/" method="POST">
<p>Username<input name="username">
<p>Password<input name="password" type="password">
<p><input name="login" type="submit" value="login">
<?php
$conn = ftp_connect("ftp.yourwebsite.com") or die("Could not connect");
ftp_login($conn,$login,$password);// print current directory
?>
</form>
I don't have an php server handy so think of this as pseudo code.
hth
|

04-15-2006, 08:12 AM
|
 |
Junior Member
|
|
Join Date: 04-14-06
Location: Boston
Posts: 18
|
|
Thanks Caroline. It's not working - perhaps its not 'smart enough?' I'd like people to be able to post files and delete files - just like a normal FTP through browser session.
I changed your php section to read '$username' instead of '$login' to match the form portion - otherwise it gave php errors 'on line 3.'
Now when I try to do login and pass (either IE or Firefox) with 'specificuser@website.com' and 'password' it takes me to a blank 'ftp.php' webpage with no FTP status in the URL - it just reads:
http://www.website.com/ftp.php
Whereas it should have initially connected with:
ftp://specificuser@website.com
|

04-15-2006, 08:20 AM
|
 |
v7n Mentor
|
|
Join Date: 10-13-03
Location: Tuscaloosa, AL or Atlanta
Posts: 2,527
|
|
cleo the ftp:// syntax is for letting it be easier to input into IE or another browser and connect
ftp://user:pass@site.com
actually connects to site.com with the username user and password pass.
do not use the @ format in your script
|

04-15-2006, 08:40 AM
|
 |
Junior Member
|
|
Join Date: 04-14-06
Location: Boston
Posts: 18
|
|
Hi Kyle. There isn't any '@' symbol in my script.
The user has to to use a username with 'username@website.com'. This is automatically created by my hosting's CPanel FTP account creation.
So I cannot login with your method using:
ftp://username@website.com:password@website.com - doesnt work.
I can sorta login with ftp://username:password@website.com. It then brings up another IE popupwindow asking for the username and pass again. Again the username is 'username@website.com' and not simply 'username'.
But what is the code to accomdate this?
Caroline's above doesnt work and the first code which I posted (which I'd like to use) forces the end user to manually enter in the FTP site they want to connect to (a major inconvenience as I 'know' where they should be connecting to.)
|

04-15-2006, 08:50 AM
|
 |
v7n Mentor
|
|
Join Date: 10-13-03
Location: Tuscaloosa, AL or Atlanta
Posts: 2,527
|
|
|
ah i see, i misunderstood, you should be able to login with
$user = "blah@blah.com";
|

04-15-2006, 09:04 AM
|
 |
Junior Member
|
|
Join Date: 04-14-06
Location: Boston
Posts: 18
|
|
|
Umm. Thanks but now you're confounding me even more - that doesn't solve the issue unless you don't mind showing me appropriate code. Unfortunately I don't kow PHP syntax.
Does anyone have a script that could accomodate this situation?
@Caroline - please don't misinterpret what I wrote - when I said 'smart enough' I was refering to the server's ability/inability to direct people to the appropriate sections.
Last edited by cleo; 04-15-2006 at 09:09 AM.
|

04-15-2006, 09:26 AM
|
 |
v7n Mentor
|
|
Join Date: 10-13-03
Location: Tuscaloosa, AL or Atlanta
Posts: 2,527
|
|
PHP Code:
$ftp_server = "site.com"; $ftp_user_name = "user@site.com"; $ftp_user_pass = "pass"; $conn_id = ftp_connect($ftp_server); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); if ((!$conn_id) || (!$login_result)) { echo "FTP connection has failed!"; echo "Attempted to connect to $ftp_server for user $ftp_user_name"; exit; } else { echo "Connected to $ftp_server, for user $ftp_user_name"; }
more info - http://us3.php.net/ftp
|

04-15-2006, 09:27 AM
|
 |
Junior Member
|
|
Join Date: 04-14-06
Location: Boston
Posts: 18
|
|
I should add that I guess this would be considered FTP over a proxy. I found this snippet on http://us2.php.net/ftp":
PHP Code:
$ftp_server = "proxy"; f.e. 123.456.789.10
$ftp_user_name = "username@ftpserver"; f.e. [email]exampleuk@www.example.uk[/email]
$ftp_user_pass = "password";
$conn_id = ftp_connect($ftp_server, 2121);
$login_result = ftp_login( $conn_id, $ftp_user_name, $ftp_user_pass );
I don't know how to implement this...
|

04-15-2006, 10:02 AM
|
 |
Junior Member
|
|
Join Date: 04-14-06
Location: Boston
Posts: 18
|
|
Here is the HTML page which sends this information:
Code:
<form action="ftp.php/" method="POST">
<p><span class="logintext">Username</span>
<input name="username"">
</p>
<p><span class="logintext">Password</span>
<input name="password" type="password">
</p>
<p><input name="login" type="submit" value="login"></p>
</form>
Last edited by cleo; 04-15-2006 at 10:17 AM.
|

04-15-2006, 10:19 AM
|
 |
Contributing Member
|
|
Join Date: 04-07-06
Location: Manchester, NH
Posts: 722
|
|
cleo, the thing that's messed up here is the difference between:
1) using an ftp client to connect
2) using a browser to connect
3) using php code to connect
The user@ftpserver.com syntax is only relevant to #2.
#1 and #3 are compiled code, not a browser request. That's a big difference.
Do not think of user@ftpserver.com as a requirement when coding in PHP. PHP is a software language, the interpreter will send the appropriate syntax to the ftp server. You must always give php what it wants and let it do the translation for you.
Your users are not using a proxy. It's ok to throw that code away.
Can you post the php error from line 3?
|

04-15-2006, 12:03 PM
|
 |
Junior Member
|
|
Join Date: 04-14-06
Location: Boston
Posts: 18
|
|
|
Hi Caroline. I just reposted your code to my site. All I get now is a blank browser screen. The URL reads 'http://www.website.com/ftp.php/'
I say that I think i'm 'proxied' cause I'm on a Virtual Host setup with Total Choice Hosting and all my FTP logins/usernames have 'username@website.com' format versus a typical 'username' all by itself.
Last edited by cleo; 04-15-2006 at 12:10 PM.
|

04-15-2006, 06:14 PM
|
 |
Contributing Member
|
|
Join Date: 04-07-06
Location: Manchester, NH
Posts: 722
|
|
Charles --
(a) my code doesn't have your real ftp address in it
(b) the username@ftpaddress.com syntax is for browsers, not php
(c) I did say it was pseudo code as I can't easily test it, and even if I could, I don't know your server's ftp settings
(d) have you considered going to guru.com or the like and buying an hour of someone's time?
hth
|

04-15-2006, 06:56 PM
|
 |
Junior Member
|
|
Join Date: 04-14-06
Location: Boston
Posts: 18
|
|
a) I realize this. It's pretty apparent.
b) In order to login, you still have to use this. With the full name (username@website.com) at least I get a blank screen. With the abbreviated name (username) I get an error:
'Warning: ftp_login(): Authentication failed, sorry in /home/oxnetzw/public_html/ftp.php on line 3'
c) I appreciate all of your help - youre kind enough to respond and try to help. 
d) I'm pretty flat-out right now - and then I had thought it was something simple that I was missing that would have been simple to answer.
|

04-15-2006, 07:12 PM
|
 |
Contributing Member
|
|
Join Date: 04-07-06
Location: Manchester, NH
Posts: 722
|
|
Well now I'm too curious to let it go.
Contact me privately with the credentials if you want me to fix the php script.
But I only promise 15 minutes or so, after that I have to stop messin' around:
|

04-15-2006, 09:29 PM
|
 |
Contributing Member
|
|
Join Date: 04-07-06
Location: Manchester, NH
Posts: 722
|
|
OK so a lot of what was wrong with the code was that the variables were never set.
Absolutely no guarantees, but it does connect to the ftp server given the user name and password provided.
Hope you're good with the rest of it.
You could have it "just conect" but you'll just get a blank web page. So I added back in the file operations.
The main dir functions work. Some won't until you set the vars I commented.
I got the file upload as far as executing, but it's failing, maybe a permission issue, something you can show your ISP.
Note
ftp.php
PHP Code:
<?php
$xdebug=0;
if ($xdebug==1)
{
print "POST<br />";
while (list($k,$v) = each($_POST))
{
print ($k . ": " . $v . "<br />");
}
print "REQUEST<br />";
while (list($k,$v)=each ($_REQUEST))
{
print ($k . ": " . $v . "<br />");
}
}
main();
function main()
{
if (isset($_REQUEST["username"]) && isset($_REQUEST["password"]))
{
$username=$_REQUEST["username"];
$password=$_REQUEST["password"];
//print ("username: " . $username . "<br />");
//print ("password: " . $password . "<br />");
connect_ftp($username, $password);
}
elseif (isset($_POST["username"]) && isset($_POST["password"]))
{
$username=$_POST["username"];
$password=$_POST["password"];
//print ("username: " . $username . "<br />");
//print ("password: " . $password . "<br />");
connect_ftp($username, $password);
}
else
{
print "User name/password not set<br />";
}
}
// function to give dir listing stuff
function dir_funk ($username, $password,$ftp) {
// dir name
$dir=ftp_pwd($ftp);
// dir listing array
$dirlist=ftp_rawlist($ftp,$dir);
// print the directory listing
$funk = "<html><body><p>current directory: <b> $dir </b></p>";
$funk .= "<p><a href=\"ftp.php?&updir=$dir\">go up one level</a>
</p>";
$funk .= "<p>
<table cellspacing=0 cellpadding=2 border=1>
<tr><td><b>permissions</b></td><td><b>file/directory</b></td>
<td><b>download</b></td><td><b>delete</b></td>
<td><b>chmod</b></td><td><b>rename</b></td>
</tr>
";
while(list($i,$thingy)=each($dirlist)) {
$thingy=preg_replace("/\s+/", " ", $thingy);
if($i==0) {
echo "";
} else {
list($chmod,$thing,$owner,$group,$size,$month,$day,$time,$filename)=explode(" ",$thingy);
if(ereg("d",$chmod)) {
$funk .= "<tr><td>$chmod</td><td><a href=\"ftp.php?dir=$dir/$filename\">$filename</a></td>
<td>dir</td>
<td><a href=\"ftp.php?delete=dir&thingy=$dir/$filename\">delete</a></td>
<td><a href=\"ftp.php?chmod=1&thingy=$dir/$filename\">chmod</a></td>
<td><a href=\"ftp.php?rename=$dir/$filename\">rename</a></td>
</tr>";
} else {
$funk .= "<tr><td>$chmod</td><td>$filename</td>
<td><a href=\"ftp.php?dl=1&file=$dir/$filename\">d/l ($size)</a></td>
<td><a href=\"ftp.php?delete=file&thingy=$dir/$filename\">delete</a></td>
<td><a href=\"ftp.php?chmod=1&thingy=$dir/$filename\">chmod</a></td>
<td><a href=\"ftp.php?rename=$dir/$filename\">rename</a></td>
</tr>";
}
}
}
$funk .= "</table></p>";
$funk .= "<p>Create a new directory<br>
<form action=\"ftp.php\" method=\"POST\">
<input type=\"hidden\" name=\"username\" value=\"$username\">
<input type=\"hidden\" name=\"password\" value=\"$password\">
<input size=\"15\" name=\"name\">
<input type=\"hidden\" name=\"current_dir\" value=\"$dir\">
<input type=\"submit\" name=\"newdir\" value=\"create_dir\">
</form></p>";
$funk .= "<p>Upload a local file<br>
<form action=\"ftp.php\" method=\"POST\">
<input type=\"file\" name=\"localfile\"><br>
<input type=\"hidden\" name=\"current_dir\" value=\"$dir\">
<input type=\"submit\" name=\"upload\" value=\"upload_file\">
</form></p>";
$funk .= "</body></html>";
return $funk;
}
function print_login_form()
{
echo "<html><body><p><b>ftp login</b><hr></p>
<form method=\"POST\">
<p>Your server (eg ft)<br> <input size=\"30\" name=\"server\"></p>
<p>Username <br> <input size=\"30\" name=\"username\"></p>
<p>Password <br> <input size=\"30\" name=\"password\"></p>
<p><input type=\"submit\" name=\"login\" value=\"login\"></p>
</form></body></html>";
}
function connect_ftp($username, $password)
{
//print $username . "<br />";
//print $password . "<br />";
if (isset($_REQUEST["thingy"]))
{
$thingy= $_REQUEST["thingy"];
}
//** charles do above for vars below
/*
$_REQUEST["thingy"]
$_REQUEST["chmod"]
$_REQUEST["rename"]
$_REQUEST["dl"]
$_REQUEST["delete"]
$_REQUEST["updir"]
$_REQUEST["dir"]
*/
if (isset($_POST["dir"]))
{
$dir=$_POST["dir"];
}
if (isset ($_POST["upload"]))
{
$upload=$_POST["upload"];
}
if (isset($_POST["localfile"]))
{
$localfile=$_POST["localfile"];
}
if (isset($_POST["current_dir"]))
{
$current_dir=$_POST["current_dir"];
}
if (isset($_POST["newdir"])) {
$newdir=$_POST["newdir"];
}
if (isset($_POST["file"])) {
$file=$_POST["file"];
}
if (isset($_POST["dir"])) {
$dir=$_POST["dir"];
}
if (isset($_POST["local"])) {
$local=$_POST["local"];
}
if (isset($_POST["dl"])) {
$dl = $_POST["dl"];
}
if (isset($_POST["get"]))
{
$get = $_POST["get"];
}
/// Charles do this for these vars too: delete, thingy, chmod, filename
if (isset($_REQUEST["thingy"]))
{
$dl=$_REQUEST["dl"];
}
// try to connect or die with an error
$server="ftp.lunarstudio.com";
$ftp=ftp_connect($server) or die("invalid server");
// try to login or die with error
$conn=ftp_login($ftp,$username,$password) or die("login failed for some reason");
// set a cookie so the !$login form above is never displayed
setcookie("login","active");
// set goody cookies
setcookie("server",$server);
setcookie("username",$username);
setcookie("password",$password);
if($dir) {
ftp_chdir($ftp,$dir);
echo dir_funk($username, $password,$ftp);
} elseif($dl) {
if($get) {
if(!$local) {
die("please enter a value");
}
ftp_get($ftp, $local, $file, FTP_BINARY);
echo funk_die(normal);
} else {
echo "<html><body>";
echo "download file";
$size=ftp_size($ftp,$file);
$time=ftp_mdtm($ftp,$file);
$time=date("d M Y, H i",$time);
echo "<p><table cellspacing=0 cellpadding=2 border=1>
<tr><td><b>filename</b></td><td><b>size</b></td>
<td><b>date modified</b></td></tr>
<tr><td>$file</td><td>$size</td><td>$time</td></tr></table>";
echo "<form action=\"ftp.php\" method=\"POST\">
where to download the file to (/home/me/file.txt or c:/file.txt):<br>
<INPUT NAME=\"local\" size=\"40\">
<input type=\"hidden\" name=\"dl\" value=\"1\">
<input type=\"hidden\" name=\"file\" value=\"$file\"><br>
<INPUT TYPE=\"submit\" name=\"get\" VALUE=\"download file\">
</FORM>";
echo "</body></html>";
}
} elseif($rename) {
if($do) {
if(!$val) {
die("please enter a value");
}
ftp_rename($ftp, $rename, $val);
echo funk_die(normal);
} else {
echo "<html><body>
rename this file: $rename
<p>
<form action=\"ftp.php\" method=\"POST\">
Rename to: <input size=\"50\" name=\"val\" value=\"$rename\"><br>
<input type=\"hidden\" name=\"rename\" value=\"$rename\">
<input type=\"submit\" name=\"do\" value=\"rename\">
</form>
</body></html>";
}
} elseif($chmod) {
if($do) {
if(!$val) {
die("please enter a value");
}
$cmd="CHMOD $val $file";
ftp_site($ftp, $cmd);
echo funk_die(normal);
} else {
echo "<html><body>
chmod this file: $thingy
<p>
<form action=\"ftp.php\" method=\"POST\">
<input size=\"4\" name=\"val\" maxlength=\"4\"> CHMOD value<br>
<input type=\"hidden\" name=\"file\" value=\"$thingy\">
<input type=\"hidden\" name=\"chmod\" value=\"1\">
<input type=\"submit\" name=\"do\" value=\"chmod\">
</form>
</body></html>";
}
} elseif($delete) {
if($delete=='file') {
ftp_delete($ftp, $thingy);
} elseif($delete=='dir') {
ftp_rmdir($ftp, $thingy);
}
echo funk_die(normal);
} elseif($upload) {
if(!$localfile) { die("please enter a file"); }
$file = substr( strrchr( $localfile, "/" ), 1 );
$put_thingy = $current_dir . "/" . $file;
print ($put_thingy . "<br />");
print ($localfile . "<br />");
$put = ftp_put($ftp, $put_thingy, $localfile, FTP_BINARY);
if ($put==true)
{
print "file ok<br />";
}
else
{
print "file bad<br />";
}
// echo funk_die(normal);
} elseif($newdir) {
if(!$name) { die("please enter a name"); }
$newdir = $current_dir . "/" . $name;
ftp_mkdir($ftp,$newdir);
echo funk_die(normal);
} elseif($updir) {
$newdir = str_replace( substr( strrchr( $updir, "/" ), 1 ) , "", $updir);
ftp_chdir($ftp,$newdir);
echo dir_funk($username, $password,$ftp);
} else {
echo dir_funk($username, $password,$ftp);
}
}
function funk_die($msg) {
if($msg=='normal') {
return "<html><body><a href=\"ftp.php\">back</a></body></html>";
}
}
?>
|

04-16-2006, 11:19 AM
|
 |
Junior Member
|
|
Join Date: 04-14-06
Location: Boston
Posts: 18
|
|
|
Caroline. You are absolutely wonderful! This had to take you way beyond your alloted 15 minutes of time spent. I appreciate all of your help in these matters.
I am currently in the process of tinkering around with the code and trying to comprehend it. I'll let you know how it goes. So far, I've managed to break plenty of things lol.
A bit off-topic, I looked at your website and you have some great skills. I'm impressed with the programming support group you have founded as well as your generous work with the homeless shelter. It's great to know that there are still altruistic people out there.
|

04-16-2006, 03:00 PM
|
 |
Contributing Member
|
|
Join Date: 04-07-06
Location: Manchester, NH
Posts: 722
|
|
|
'hope you enjoy it, happy to help.
|

05-14-2010, 09:18 AM
|
|
Junior Member
|
|
Join Date: 05-14-10
Posts: 3
|
|
Hi, Great forum.
I came across this while looking for a solution to add web browser based ftp to my companies site. We have subfolders and would like clients locked in to these which has been set up on the server, however when I test these accounts I enter the root folder and no the the folder I specified on the hosting ftp control panel.
Any help would be much appreciated.
Thanks.
|

05-14-2010, 09:21 AM
|
 |
Super Moderator
|
|
Join Date: 12-31-07
Location: Medford, NJ
Posts: 32,689
|
|
|
Please try not to bump a 4 year old thread.
You may create your own if you need some help.
|
|
Currently Active Users Viewing This Thread: 3 (0 members and 3 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 02:11 AM.
Powered by vBulletin Copyright © 2000-2011 Jelsoft Enterprises Limited.
Copyright © 2003 - 2011 Escalate Media LP
|
|
|