php CURLFile phpmem
The code php://mem is not a valid file path for the PHP CURLFile class.
The CURLFile class is used to create a file object that can be sent with a cURL request. It requires a valid file path as its parameter, not a stream wrapper like php://mem.
If you want to send a file that is stored in memory, you can use the CURLOPT_POSTFIELDS option in cURL to send the file contents as a string. Here's an example:
$fileContents = 'This is the contents of the file';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/upload.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, ['file' => $fileContents]);
curl_exec($ch);
curl_close($ch);
In the example above, the file contents are stored in the $fileContents variable, and then passed as a parameter to the CURLOPT_POSTFIELDS option. The server-side script at http://example.com/upload.php can then access the file contents using $_POST['file']
原文地址: http://www.cveoy.top/t/topic/iXBJ 著作权归作者所有。请勿转载和采集!