PHP的FTP學習(二)[轉自奧索]

來源:互聯網
上載者:User
現在終於到了我們的第三個檔案,include.php 它為程式建立起一個使用者介面。
"include.php" 包含三個表單,一些PHP代碼擷取當前的目錄列表並將它們存入三個變數
$files (包括目前的目錄下的檔案),
$file_sizes (相應的檔案大小),
and $dirs (包含子目錄名)
第一個表單使用$dirs 產生一個下拉式目錄列表,對應於“action=CWD”。
第二個表單使用$files    $file_sizes建立一個可用的檔案清單,每一個檔案使用一個checkbox。這個表單的action對應於"action=Delete" and "action=Download"
第三個表單用來上傳一個檔案到FTP網站,如下:
--------------------------------------------------------------------------------
<form enctype="multipart/form-data" action=actions.php4 method=post>
...
<input type=file name=upfile>
...
</form>
--------------------------------------------------------------------------------
當PHP以這種方式接收到一個檔案名稱,一些變數就產生了,這些變數指定檔案的大小,一個臨時的檔案名稱以及檔案的類型,最初的檔案名稱存在$upfile_name,一旦上傳後檔案名稱便存入$upfile中(這個變數是由PHP自己建立的)
通過這些資訊,我們就可以建立以下的語句了:
--------------------------------------------------------------------------------
ftp_put($result, $upfile_name, $upfile, FTP_BINARY);
--------------------------------------------------------------------------------
以下是代碼清單:
--------------------------------------------------------------------------------
<!-- code for index.html begins here -->
<html>
<head>
<basefont face=arial>
</head>
<body>
<table border=0 align=center>
<form action="actions.php" method=post>
<input type=hidden name=action value=CWD>
<tr>
<td>
Server
</td>
<td>
<input type=text name=server>
</td>
</tr>
<tr>
<td>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.