App Engine PHP upload file

2019-09-02 02:49发布

I'm trying to figure out how to upload my files correctly to Google App Engine. Everything works if I declare a handler for a static directory named images - there's no upload statement needed - but if I try to use regex to upload only web graphics, the files (evidently) aren't uploaded.

Here's my app.yaml:

application: static-files-demo-999
version: 1
runtime: php
api_version: 1

handlers:
- url: /styles
  static_dir: styles

- url: /images/(.*\.(gif|png|jpg))
  static_files: static/images/\1
  upload: images/(.*\.(gif|png|jpg))

- url: /.*
  script: main.php

As far as I can tell, it's exactly like the docs say, just targeting my images folder. Can anyone spot what I'm doing wrong?

Much appreciated!

Best - Joe

1条回答
在下西门庆
2楼-- · 2019-09-02 02:55

Solved it. I was following the documentation too literally and including the static folder in my path. Here's the correct code:

- url: /images/(.*\.(gif|png|jpg))
  static_files: images/\1
  upload: images/(.*\.(gif|png|jpg))

Hopefully this will stop others from making the same (bonehead) mistake.

  • Joe
查看更多
登录 后发表回答