upload pictures using curl. Keep reporting timeout errors.
Operation timed out after 30000 milliseconds with 0 bytes received
my curl function is as follows:
function myCurl($data, $file = null)
{
if (!empty($file)) {
$file_obj = curl_file_create(realpath($file), "image/png", "550759_yuan521.png");
$data["imgs"] = $file_obj;
$data = http_build_query($data);
}
$opt = [
CURLOPT_URL => "http://localhost/test/2.php", //
CURLOPT_POST => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => 0,
CURLOPT_POSTFIELDS => $data,
CURLOPT_SSL_VERIFYPEER => 0
];
$ch = curl_init();
curl_setopt_array($ch, $opt);
$output = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
if ($error) {
return $error;
} else {
return $output;
}
}
< hr >
2.php
wrote only one line of code
print_r($_FILES);
< hr >
php version is: php-7.0.12-nts
the size of the test image is only 100k