2012-11-07 38 views
0

我是cakePHP的新手。有人可以幫助我使用HTML 5使用CakePHP多文件上傳的代碼。任何幫助將不勝感激。cakephp - 使用cakephp進行多文件上傳的代碼

這是我到目前爲止有:

<tr> 
    <th>ID</th> 
    <th>File Name</th> 
    <th>Size</th> 
</tr> 

<?php foreach($files as $file): ?> 
    <tr> 
     <td> 
      <?php echo $file['Doc']['id'];?> 
     </td> 
     <td> 
      <?php echo $this->Html->link($file['Doc']['name'], array('controller' => 'files', 'action' => 'uploads', $file['Doc']['name'])); ?> 
     </td> 
     <td> 
      <?php echo number_format($file['Doc']['size']/1023,0).' KB';?> 
     </td> 
    </tr> 
<?php endforeach;?> 

<h1>Add a File</h1> 
<?php 
    echo $this->Form->create('Doc',array('type'=>'file')); 
    echo $this->Form->file('File'); 
    echo $this->Form->submit('Upload'); 
    echo $this->Form->end(); 
?> 
+0

請在發佈問題之前閱讀「常見問題解答」部分(鏈接在右上角),因爲這不符合StackOverflow接受的問題的要求。謝謝:) – Dave

+0

我讀過它,不知道什麼時候出錯,我會再試一次 – Ann

+0

@安 - 我已經將你的代碼添加到問題主體中了。也許現在刪除你的評論/回覆,因爲它有點混亂:) –

回答

0

你確定與使用現有的插件呢?如果是這樣,你想試試這個插件:https://github.com/srs81/CakePHP-AjaxMultiUpload/ - 支持多文件上傳,AJAX等。

+0

這個插件是否可以與CakePHP 1.2一起使用? – Ann

+0

Ah很可能不是 - 它的CakePHP 2.x. – Suman

+0

我下載並遵循自述文件中的所有說明。我仍然不確定如何使用它。它可以讓我在文件對話框中只選擇一個文件,我已經在谷歌瀏覽器和IE中試過了。 – Ann