Doc #80282 [Ver->Csd]: cannot send binary data to popen

From: Date: Tue, 27 Oct 2020 22:44:10 +0000
Subject: Doc #80282 [Ver->Csd]: cannot send binary data to popen
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-18038@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80282&edit=1 ID: 80282 Updated by: phpdocbot@php.net Reported by: vanherkmarcel at gmail dot com Summary: cannot send binary data to popen -Status: Verified +Status: Closed Type: Documentation Problem Package: Filesystem function related Operating System: Windows PHP Version: 7.4.11 Assigned To: cmb Block user comment: N Private report: N New Comment: Automatic comment on behalf of cmb Revision: http://git.php.net/?p=doc/en.git;a=commit;h=101793286959d1113af940727b5c6e2101ac2303 Log: Fix #80282: cannot send binary data to popen Previous Comments: ------------------------------------------------------------------------ [2020-10-27 18:14:34] cmb@php.net Okay, thanks for the explanation. popen() indeed defaults to text mode on Windows, what explains the reported issue. However, $mode 'wb' is supossed to enable binary mode, and it does so for me (it is important to write that as 'wb', not as 'bw' or 'w b' etc.) Since you can no longer reproduce the problem with 'wb', I'm changing to documentation bug. Please open a new ticket, if you ever stumble upon 'wb' prepending 0x0D to any 0x0A bytes. ------------------------------------------------------------------------ [2020-10-26 21:58:29] vanherkmarcel at gmail dot com Hi, Thanks for trying. I lost my test code, since I programmed around it. My exe is the CGI interface of a DICOM server (Conquest DICOM server), and I was using php to forward a POST request to is CGI client dgate.exe. By default popen($exe, "w") opens in text mode on Windows - this is not documented. popen($exe, "wb") is not documented either, and when I tried it did seem not start my exe. There may have been a mixup with PHP versions though. Marcel ------------------------------------------------------------------------ [2020-10-26 16:17:44] cmb@php.net > popen($exe, 'wb') fails I cannot reproduce that. What exactly fails? Is there some error message? Which executable do you call? ------------------------------------------------------------------------ [2020-10-24 18:19:31] vanherkmarcel at gmail dot com Description: ------------ I am attempting to send binary data to a process openened with popen under windows. However, any 0x0a is appended with a 0x0d, and there is no option to turn this of: popen($exe, 'wb') fails. Test script: --------------- $handle = popen($exe, 'w'); fwrite($handle, file_get_contents($_FILES['filetoupload']['tmp_name'])); pclose($handle) Expected result: ---------------- Data is transmitted as is without interference Actual result: -------------- 0x0a replaced by 0x0a 0x0d ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80282&edit=1

« previous php.doc.bugs (#18038) next »