在iFrame中打开FTP

I want open an FTP connection inside an iFrame, but the problem is that if the FTP connection requires a username, the popup to put the username and password is not opened, it only runs if the FTP connection requires no username.

<iframe src="ftp://server.com/"></iframe>

What Can I do?

<iframe src="ftp://user:password@server.com/"></iframe>

If that doesn't work, it's not possible at all.

What you might have to do is implement your own display of the contents of the FTP location with PHP.

You can create a connection to an FTP server and manipulate the files there with PHP quite simply. Taken from the PHP manual

// set up basic connection
$conn_id = ftp_connect($ftp_server);

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// get contents of the current directory
$contents = ftp_nlist($conn_id, ".");

// output $contents
var_dump($contents);

The above example will output something similar to:

array(3) {
  [0]=>
  string(11) "public_html"
  [1]=>
  string(10) "public_ftp"
  [2]=>
  string(3) "www"

From this point all the FTP functions are available and at your disposal.

You can use them to render an HTML representation of the files and folders listed on the FTP server and possibly also let the users perform actions on them such as

  • Renaming
  • Deletion
  • Display contents
  • etc...