in webview2 no uploaded tmp file

mpvos

New member
When uploading a file through a form the tmp file is not in the Windows temp directory or empty:
["file"]["tmp_name"] is zero bytes.

With CEF this is not a problem.
Something is amiss with the temp files in WebView
 
Unfortunately, it's a bug inside WebView2. Could you run the upload again under WebView2 with this in the receiving script:

Code:
var_dump($_FILES['file']);
var_dump($_SERVER['CONTENT_LENGTH'] ?? null, strlen(file_get_contents('php://input')));
What matters is:

  • whether tmp_name is an empty string, or a real path pointing at a file that happens to be zero bytes,
  • the value of error, which tells us a great deal on its own: 0 with a zero size, 3 for a partial upload, 6 for a missing temporary folder and 7 for a write failure are four different problems,
  • the value reported by size,
  • whether CONTENT_LENGTH matches the number of bytes actually readable from the request body.
Two more details would help: the size of the file you are uploading, since a small file and a large one do not always fail the same way, and your ExeOutput for PHP version together with the PHP version selected in the project.

In the meantime, staying on CEF is the sensible course, since you have established that it works.

One design note that may or may not apply to what you are building. An application made with ExeOutput is not a web server, and PHP inside it can read any local file directly, so a genuine HTTP upload is often unnecessary: asking the user to pick a file and then processing that path in PHP achieves the same result without the request body being involved at all. That does not excuse the behaviour you are seeing, and it is not offered as the answer to it, but if your form exists only to bring a local file into your code, it may take the problem off your critical path while we deal with ours.
 
Back
Top