dos3018
2018-02-26 01:59
浏览 40
已采纳

无法多次POST同一个文件

hopefully there is a simple change (or something overlooked). We ported a PHP application from Redhat 5.9 and PHP 5.4.14 to:

PHP 5.6.33 (cli) (built: Jan 14 2018 08:26:10)
Red Hat Enterprise Linux Server release 6.9 (Santiago)

In both cases, it is Apache 2.2.23

We have an API that allows specific applications to send POST data and sometimes files. (We use POSTMAN while testing).

In Postman, if I send a POST request as form-data (which includes a file) to "somefile.up.php", the very first time I click "Send" in Postman, at the PHP side, if I print_r on both the $_POST and $_FILES arrays, I can see all of the expected array keys and values, including $_FILES.

If I send another POST request in Postman, with all of the details the same, the $_FILES array is empty (I only see the $_POST vars printed). It would seem the file simply isn't there. The only thing that sometimes works, is select a different file for upload (in Postman) and send the request again, but then that file can only be sent once. Subsequent sends yield an empty $_FILES array.

I've checked the location of where the files get sent to (temporarily) and commonly the value of $_FILES['keyname']['tmp_name'] is /tmp/php... and the [error] value is 0 when the file arrives. I can also see the name and type of the file, along with its size. I've also checked php.ini values for post_max_size and upload_max_filesize and post_max_size is larger by 1 M.

We were able to send same file many times when the application was running under PHP 5.4.14 and Redhat 5.9

UPDATE: If I perform the action using shell (babun in this case) I can send the file properly each and every time. So my guess is that something inside Postman is occurring. This, solves my issue by about 50% of the way, only because the script that initially receives the file, has to validate its contents and then perform a Curl post to send it another server. Upon trying that, the file doesn't arrive in the $_FILES array.

UPDATE2: Sending a file from server to server issue solved by updating code. The code was using the very old 'at symbol' in front of the file name in order to get its contents. Updated the code per suggestion forget-the-at-use-curl-file-create . So at this point it's a matter of troubleshooting the Postman Standalone application.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doujiao9866 2018-03-06 23:09
    已采纳

    I have a feeling this is issue is within Postman standalone app. I saw something similar in their github issue tracker but they were older issues dating back to when Postman was only a browser extension.

    I've yet to find the answer, perhaps there are more controls or settings to mess with in the standalone Postman application.

    Seems a command line curl (with or without a file) can be made numerous times and work each time. If I make a repeat (same) call in Postman app, it seems to sometimes 'hang' and won't do anything until I click the "Cancel request" button. If I then wait a few seconds, it's once again fine.

    Thanks for reading.

    点赞 打赏 评论

相关推荐 更多相似问题