当前位置: 首页 > news >正文

青岛做网站的公司哪家好一点sem扫描电子显微镜

青岛做网站的公司哪家好一点,sem扫描电子显微镜,wordpress 主题汉化无效,网站运营内容之前测试功能写过一次,因为代码忘记保存,导致真正用到的时候怎么也想不起来当初怎么写的了,复现后还是写个文章记录一下,省的下次再忘记。 php后端 /*** 图片保存到本地*/ public function uploadLocalImage() {try {$img $thi…

之前测试功能写过一次,因为代码忘记保存,导致真正用到的时候怎么也想不起来当初怎么写的了,复现后还是写个文章记录一下,省的下次再忘记。

php后端

/*** 图片保存到本地*/
public function uploadLocalImage()
{try {$img = $this->_request->file('img');if (empty($img)) {throw new \Exception('缺少图片参数');}$writeDir = "images/".date('Ymd');$dir = "D:/phpstudy_pro/WWW/vkm_locarun_dist/dist/".$writeDir;//$dir = "local_run/" . date('Ymd'); //linux调试地址if (!file_exists($dir)) {mkdir($dir, 0777, true);}$extension = substr($img->getMimeType(), -3);if ($extension == 'bmp') {$fileName = UtilService::createOrderNo() . '.bmp';}if ($extension == 'png') {$fileName = UtilService::createOrderNo() . '.png';}else{$fileName = UtilService::createOrderNo() . '.jpg';}$imgContent = file_get_contents($img);file_put_contents($dir . '/' . $fileName, $imgContent);$localhostImg = env('CLIENT_URL') . $writeDir . '/' . $fileName;//http://127.0.0.1:8000/xxx/20231016/xxx.jpg 读取方式$this->returnSuccess($localhostImg);} catch (\Exception $e) {$this->returnFault($e->getMessage());}
}

Unity C#

/// <summary>
/// 上传文件到服务器
/// </summary>
/// <param name="filePaths">文件路径</param>
void UploadToLocalServer(string[] filePaths)
{int count = filePaths.Length;urls = new string[count];isUploaded = new bool[count];string filePath;//文件命为上传OSS时的keyfor (int i = 0; i < count; i++){int current = i;filePath = filePaths[current];if (File.Exists(filePath)){File.SetAttributes(filePath, FileAttributes.Normal);StartCoroutine(UploadToLocal(filePath, current));}else{urls[current] = "none";}}
}
IEnumerator UploadToLocal(string filePath, int index)
{byte[] fileByte = File.ReadAllBytes(filePath);WWWForm form = new WWWForm();//根据自己上传的文件修改格式,img是接口请求json参数的key, //最后一个参数是图片的mimeType, 因为上传的图片有jpg、png、bmp几种格式,此处取文件后缀和image组合字符串作为mimeTypeform.AddBinaryData("img", fileByte, Path.GetFileName(filePath), $"image/{Path.GetExtension(filePath)}");Helper.Log($"{Config.SystemConfig.sendHost}/uploadLocalImage");using (UnityWebRequest www = UnityWebRequest.Post($"{Config.SystemConfig.sendHost}/uploadLocalImage", form)){yield return www.SendWebRequest();if (www.result == UnityWebRequest.Result.ConnectionError || www.result == UnityWebRequest.Result.ProtocolError){urls[index] = "error";Helper.LogError($"[ERROR] {filePath}, msg: {www.error}");}else{string text = www.downloadHandler.text;//Helper.Log("服务器返回值" + text);JObject json = JObject.Parse(text);if (json["msg"].ToString().Equals("success")){urls[index] = json["data"].ToString();Helper.Log($"[SUCCESS] {urls[index]}");}else{urls[index] = "error";Helper.LogError($"[ERROR] {filePath}, msg: {text}");}isUploaded[index] = true;}}
}

搞定。

http://www.hkea.cn/news/304818/

相关文章:

  • 用wordpress制作网站模板沈阳seo
  • 优化一个网站多少钱宜昌网站seo
  • 刚做的网站怎么才能搜索到枸橼酸西地那非片功效效及作用
  • 罗湖区网站公司专业模板建站
  • 哪有备案好的网站国产系统2345
  • 网站开发怎么让别人看到最新营销模式有哪些
  • ssm网站开发源码百度推广多少钱一个月
  • 手游门户网站建设appstore关键词优化
  • 齐河网站开发seo服务内容
  • 北京微信网站建设费用想卖产品怎么推广宣传
  • 网站上线的步骤厦门网站推广公司哪家好
  • 网站做app的软件有哪些百度一下你就知道下载
  • 界面设计的重要性百度seo关键词排名推荐
  • 股票做T网站直播营销
  • 北京手机网站建设公司排名技术优化seo
  • wordpress可爱的主题seo优化教程
  • 自己可以申请网站做外卖吗网站描述和关键词怎么写
  • 公司网站网页设计seo站长工具推广平台
  • 重庆南岸营销型网站建设公司哪家专业真实的网站制作
  • 郑州企业网站建设兼职推广渠道
  • 网站哪些数据优化大师的作用
  • 政府网站集约化建设总结营销软文推广平台
  • 学网站开发跟那个专业最相近百度站长平台注册
  • 网站开发python电脑培训班有哪些科目
  • 惠州响应式网站哪家好云盘搜索
  • spring做网站合肥seo排名收费
  • 做58网站怎么赚钱二十个优化
  • 做企业手机网站北京seo网站开发
  • 关于网站建设中原创文章的一些想法体育热点新闻
  • 天河做网站开发免费留电话号码的广告