Deprecated: Optional parameter $keys declared before required parameter $cms_id is implicitly treated as a required parameter in /home/www/dev/work/class/blog/CmsKey.php on line 75

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\main::$outlink is deprecated in /home/www/dev/work/website/lvesu/template/blog/cms/cms.tpl on line 2

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\main::$status is deprecated in /home/www/dev/work/website/lvesu/template/blog/index.head.php on line 2
用PHP POST提交文件 - 互联网笔记

略微加速

略速 - 互联网笔记

用PHP POST提交文件

2020-12-11 leiting (3298阅读)

标签 PHP

if($_FILES['icon_img'])
{
    $file=file_get_contents($_FILES['icon_img']['tmp_name']);
    $filename=str_replace('%','',rawurlencode($_FILES['icon_img']['name']));
    $filetype=$_FILES['icon_img']['type'];
    $content = "------neirongqianmianyaoduojialianggegang\r\n".
    "Content-Disposition: form-data; name=\"purchase_image_file\"; filename=\"$filename\"\r\n".
    "Content-Type: $filetype\r\n\r\n";
    $content.="$file\r\n------neirongqianmianyaoduojialianggegang--\r\n";
    $options = array(
        'http' => array(
        'method' => 'POST',
        'header' => "Content-Type: multipart/form-data; boundary=----neirongqianmianyaoduojialianggegang\r\n",
        'content' => $content,
        )
    );
    $res=json_decode(file_get_contents('http://www.xxx.com/upload', false, stream_context_create($options)),true);
}


北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3