2016-04-07 147 views
0

有沒有辦法允許在Google App Engine的一個請求中上傳多個文件? This guide讓我相信你可以,但我複製了演示,它似乎不適合我。Google App Engine PHP:多文件上傳

的app.yaml

application: splink-api 
runtime:  php55 
api_version: 1 

default_expiration: "1h" 

handlers: 
    - url: /handle_upload 
     script: handle_upload.php 

    - url: /direct_upload 
     script:direct_upload.php 

direct_upload.php

<?php 
// Direct uploads requires PHP 5.5 on App Engine. 
if (strncmp("5.5", phpversion(), strlen("5.5")) != 0) { 
    die("Direct uploads require the PHP 5.5 runtime. Your runtime: " . phpversion()); 
} 
?> 
<html> 
<body> 
    <form action="handle_upload" method="post" enctype="multipart/form-data"> 
     Send these files:<p/> 
     <input name="userfile[]" type="file" multiple="multiple"/><p/> 
     <input type="submit" value="Send files" /> 
    </form> 
</body> 
</html> 

handle_upload.php

<?php 

header('Content-Type: text/plain'); 
print_r($_FILES); 

結果:

Array 
(
    [userfile] => Array 
     (
      [name] => Array 
       (
        [0] => arryn.jpg 
       ) 

      [type] => Array 
       (
        [0] => image/jpeg 
       ) 

      [tmp_name] => Array 
       (
        [0] => vfs://root/uploads/0 
       ) 

      [error] => Array 
       (
        [0] => 0 
       ) 

      [size] => Array 
       (
        [0] => 721332 
       ) 

     ) 

) 

使用一個簡單的PHP服務器在同一代碼的結果:

Array 
(
    [userfile] => Array 
     (
      [name] => Array 
       (
        [0] => arryn.jpg 
        [1] => baratheon.jpg 
       ) 

      [type] => Array 
       (
        [0] => image/jpeg 
        [1] => image/jpeg 
       ) 

      [tmp_name] => Array 
       (
        [0] => /private/var/folders/rc/z5ky3d3s29v0bsdllnzvpj8r0000gn/T/phpUt5H8S 
        [1] => /private/var/folders/rc/z5ky3d3s29v0bsdllnzvpj8r0000gn/T/phpijjaNO 
       ) 

      [error] => Array 
       (
        [0] => 0 
        [1] => 0 
       ) 

      [size] => Array 
       (
        [0] => 721332 
        [1] => 234717 
       ) 

     ) 

) 

無法看到在日誌中的任何錯誤,我已經用非常小的文件,試圖讓不應該一個問題。在開發服務器上進行本地測試。有任何想法嗎?

回答

1

php.ini我需要改變

max_file_uploads: 1 

max_file_uploads: 100 

這是不以任何我看着演示或文檔中非常有據可查。