| | |
using the $ftp_server
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Nov 2006
Posts: 39
Reputation:
Solved Threads: 0
I am trying to use a switch statement and want the action to be log into a ftp server.
I am not able to get it to work...can anyone help?
here is what I have now....Thanks everyone in advance.
$ftp_server = "ftp://MyFtpSite.com";
$ftp_server = $employeeftp;
switch($attn1) { // this is from the other page
case 'employees': // case employees, it should take you to my ftp site
$conn_id = ftp_connect($employeeftp);
break;
}
I am not able to get it to work...can anyone help?
here is what I have now....Thanks everyone in advance.
$ftp_server = "ftp://MyFtpSite.com";
$ftp_server = $employeeftp;
switch($attn1) { // this is from the other page
case 'employees': // case employees, it should take you to my ftp site
$conn_id = ftp_connect($employeeftp);
break;
}
You do not include the protocol with the servername when you use ftp_connect so change this line:
$ftp_server = "ftp://MyFtpSite.com";
to this:
$ftp_server = "MyFtpSite.com";
$ftp_server = "ftp://MyFtpSite.com";
to this:
$ftp_server = "MyFtpSite.com";
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss
-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
•
•
Join Date: Nov 2006
Posts: 39
Reputation:
Solved Threads: 0
Thanks for the help. I have been at this for days now. So far I have got the switch command to work to send out a email if the "case" is correct. I now want to have the CASE go to a ftp site or a URL.
Here is where I am at. Please any help is good help.
-----------------------------------------
Here is where I am at. Please any help is good help.
-----------------------------------------
php Syntax (Toggle Plain Text)
$ftp_server = "MyFtpSite"; // after your input..thanks $ftp_user = "myName@com"; $FTP_pass = "mypassword"; $conn_id = ftp_connect($ftp_server) or die("could not do it erich"); switch($attn1) { case 'employees': if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) { echo "you did it erich"; } else { echo "nice try erich"; } break; }
Last edited by cscgal; Oct 12th, 2008 at 11:12 am. Reason: Added code tags
This function always works for me:
php Syntax (Toggle Plain Text)
<?php /** * connect to ftp * @access public * * return object or false */ function connect_ftp() { //FTP connection $ftp_server="servername"; $ftp_user_name="username"; $ftp_user_pass="password"; $conn=ftp_connect($ftp_server); //if ($conn) echo "Server connected: $ftp_server<br>"; $login=ftp_login($conn, $ftp_user_name, $ftp_user_pass); //if ($login) echo "User '$ftp_user_name' logged in.<br>"; return $login?$conn:false; } switch($attn1) { case 'employees': if($conn_id = connect_ftp()) { echo "you did it erich"; } else { echo "nice try erich"; } break; } ?>
Last edited by R0bb0b; Oct 12th, 2008 at 9:36 pm.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss
-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
•
•
•
•
Sweet, I got it to connect but now thats all it says is connected....Is there a way of viewing my files and folders from my ftp site so I can add to them? LOL Thanks so much for heping me. I am starting to get this.
Erich
http://us.php.net/manual/en/ref.ftp.php
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss
-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
I don't know how much you know about functions but you will want to pass the username and password to the function as arguments, here is the manual on function arguments:
http://us.php.net/manual/en/functions.arguments.php
http://us.php.net/manual/en/functions.arguments.php
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss
-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
![]() |
Similar Threads
- Great Freewares (Windows Software)
- FTP problem (PHP)
- apache as an ftp server (IT Professionals' Lounge)
- ftp inside function in korn shell script (Legacy and Other Languages)
Other Threads in the PHP Forum
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email error fcc file files folder form forms freelancing function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail menu method mlm mod_rewrite multiple mysql oop pageing pagerank parse paypal pdf php printer problem query radio random recursion recursiveloop regex remote script search server sessions sms soap source space sql structure subversion support! syntax system table template tutorial update upload url validation validator variable video web xml youtube





