2016-04-07 152 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 

这是不以任何我看着演示或文档中非常有据可查。