php做接口写图片上传的方法

        $file_name = base64_decode($_REQUEST['images']);
        //$status    = $_REQUEST['status'];//是否作为头像 1 作为头像 0 不做头像
        $upfile="uploads/photo/".time().'.jpg';
        $file=$_SERVER['DOCUMENT_ROOT']."/uploads/photo/".time().'.jpg';
        $m=fopen($file,"w");//当参数为"w"时是将内容覆盖写入文件,而当参数为"a"时是将内容追加写入。
        //$content=$result['keyword']."\t\t\n";
        fwrite($m,$file_name);
        fclose($m);


你可能感兴趣的:(接口,图片上传)