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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 怎样才能让鼠标沿着线条的中心线轨迹移动
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?