这是我正常的文件上传代码。
HTML
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
<input name="theFile" type="file" />
<input name="Submit" type="submit" value="Upload">
</form>
PHP Variables to receive file
$fileName = $_FILES['theFile']['name'];
$fileTempName = $_FILES['theFile']['tmp_name'];
现在我想使用远程上传。
所以我创建了一个这样的表单
<form method="POST" action="<?=$self?>">
<input type="text" name="file[]" size="45" value="">
<input name="submit" type="submit" id="submit" value="submit" accesskey="s"></p>
</form>
我必须在上面的表格中输入文件 url。当我提交表单时,我希望文件文件详细信息存储在这些变量中 $fileName,$fileTempName
我不希望它们存储在本地。我正在尝试在 amazon s3 上传中使用这些变量。你们能帮帮我吗?谢谢
最佳答案
试试这个:
$ch = curl_init("http://www.remotepage.com/upload.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('fileupload' => '@'.$_FILES['theFile']['tmp_name']));
echo curl_exec($ch);
关于php - 需要远程文件上传帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6963742/