doulu1945 2012-08-23 14:03
浏览 9
已采纳

无法通过php上传文件

I am submitting a file with the following html code to a php file. What I want to do is that get that file in php and then set the file as a parameter's value for cURL as postfields and then execute the url, How can I do that?

Here is the 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>

Here is the 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); 
} 
?>

Thanks in advance!

  • 写回答

2条回答 默认 最新

  • dongqing483174 2012-08-23 14:20
    关注

    try

    $_FILES["file"]["tmp_name"]
    

    instead, until you move the uploaded file it is stored in a temporary location

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)