duanpuqi9965 2016-06-25 00:58
浏览 59
已采纳

如何在只知道路径的情况下移动临时文件?

I just can get the temp file path,like D:\XAMPP\tmp\phpE185.tmp...But the $_FILE array is null,because I do a transport from a url to another url.So how to move this temp file?

here is my code:

 class UserController extends Controller
{


public function getRank(){

    echo "waht";
}

public function uploadTrans(Request $request){

    $image = $request->image;
    $name = $request->name;

    $image = urlencode($image);
    $curlPost = "name=$name&image=$image";

    $uploadApi = "http://mdx.ittun.com/authprac/public/upload";
    $ch  = curl_init();
    curl_setopt($ch,CURLOPT_URL,$uploadApi);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch,CURLOPT_POSTFIELDS,$curlPost);
    $output = curl_exec($ch);
    curl_close($ch);
    echo $output;

}
public function upload (Request $request){


    $fileTempName = $request->image;
    print_r($fileTempName);

 //   here I just can get the temp file path..$_FILES array is null
    }
}
  • 写回答

1条回答 默认 最新

  • doufan3408 2016-06-25 01:32
    关注

    PHP has a move_uploaded_file() function for this purpose.

    Since you've tagged your question with laravel, see their docs regarding uploaded files:

    $request->file('photo')->move($destinationPath);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用verilog实现tanh函数和softplus函数
  • ¥15 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启
  • ¥15 51寻迹小车定点寻迹
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题
  • ¥15 idea自动补全键位冲突
  • ¥15 请教一下写代码,代码好难
  • ¥15 iis10中如何阻止别人网站重定向到我的网站
  • ¥15 滑块验证码移动速度不一致问题