我正在将具有以下 html 代码的文件提交到 php 文件。我想做的是在php中获取该文件,然后将该文件设置为cURL的参数值作为postfields,然后执行url,我该怎么做?
这是html:
<form name="frm" id="frm" method="post" action="fileSubmit.php" enctype="multipart/form-data">
<input type="file" name="file" id="file"/>
<input type="submit" name="submit" value="submit" />
</form>
这是php
<?php
if(isset($_REQUEST['submit'])) {
$curl = curl_init("myDomain/submitFile";);
$file = "file=".file_get_contents($_FILES["file"]["name"]);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
curl_setopt($curl, CURLOPT_POST, 0);
curl_setopt($curl, CURLOPT_POSTFIELDS, $file);
$resp = curl_exec($curl);
curl_close($curl);
}
?>
提前致谢!