<form action="i am calling another php file here" method="post" enctype="multipart/form-data">
Select image to upload:
<input type="file" name="fileToUpload" value="choose">
<input type="hidden" name="upurl" value="<?php echo $upload_url;?>">
<input type="hidden" name="token" id="" value= <?php echo $access_token;?>>
<input type="submit" value="Upload Image" >
</form>
<?php
if ( isset($_FILES['fileToUpload']) ) {
$d=$_POST;
$imagePath=$_FILES['fileToUpload']['tmp_name'];
$type=$_FILES['fileToUpload']['type'];
$upload_url=$d['upurl'];
$access_token=$d['token'];
$f=$_FILES["fileToUpload"]["tmp_name"];
$ch=curl_init();
$cfile= curl_file_create($_FILES["fileToUpload"]["tmp_name"]);
$data=array("media"=>$cfile);
$header = array("authorization: Bearer $access_token",
"content-type: multipart/form-data");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data );
curl_setopt($ch, CURLOPT_URL,$upload_url);
$response=curl_exec($ch);
print_r(curl_getinfo($ch));
if($response== true){echo "file posted";}
else{echo"error";}
}
?>
我的http回复......
数组([url] =&gt; https://streetviewpublish.googleapis.com/media/user/10367060812938697279/photo/891443328548839265 [content_type] =&gt;为text / html; charset = UTF-8 [http_code] =&gt; 400 [header_size] =&gt; 446)
答案 0 :(得分:-2)
override func setElement(element: BarElement) { ... }
标题指定了正在上传的文件的类型和扩展名,这里是list of available types,看起来您需要将其设置为image / jpeg