0

Is there a way to allow multiple file uploads in one request to Google App Engine? This guide makes me believe that you can but I copied that demo and it doesn't seem to work for me.

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);

Results in:

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
                )

        )

)

Using a simple php server with the same code results in:

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
                )

        )

)

Can't see any errors in the logs and I've tried with really small files so that shouldn't be an issue. Testing locally on a dev server. Any ideas?

1 Answer 1

1

In php.ini I needed to change

max_file_uploads: 1

to

max_file_uploads: 100

This isn't very well documented in any of the demos or documentation I looked at.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.