找回密码
 立即注册
搜索

开发问题 文件上传显示成功但服务器并没有显示上传的文件

1
回复
1286
查看
[复制链接]

1

主题

1

帖子

10

积分

 楼主| 2019-7-17 09:03:18 显示全部楼层 |阅读模式
<template> <div class="mainmenu"> <text class="title">text> <div class="tp"> <image src="{{photoUri}} " class = "phu" alt="无法显示图片">image> div> <div class="lujing"> <text class="information"> {{photoSaveUri}} text> div> <input type="button" class="btn" onclick="takePhoto" value="拍照"/> <input type="button" class="btn" onclick="openPhoto" value="相册"/> div> template> <style> .mainmenu { flex-direction: column; justify-content: center; align-items: center; } .tp{ color: red; } .btn{ color: #00bfff; } .phu{ margin: 50px 0px; width: 800px; height: 300px; } style> <script> // import settings from '@android.settings'; import media from '@system.media'; import image from '@system.image'; import request from '@system.request'; // import prompt from '@system.prompt'; module.exports = { data: { title: 'menu', photoUri:'',//图片路径 photoSaveUri:' ' }, onInit() { this.$page.setTitleBar({ text: 'menu', textColor: '#ffffff', backgroundColor: '#007DFF', backgroundOpacity: 0.5, menu:true }) }, takePhoto(){ var that = this; media.takePhoto({ success: function (data) { console.log('handling success: ' + data.uri); that.photoUri = data.uri; that.photoSaveUri = data.uri; media.saveToPhotosAlbum({ uri:that.photoSaveUri, success: function () { console.log('save success'); that.photoUri = data.uri; that.photoSaveUri = data.uri; }, fail: function (data, code) { console.log('handling fail, code = ' + code); } }) request.upload({ "url": 'http://139.9.7.2:80/', "files": [ { "uri":that.photoSaveUri, } ], // method:"PUT", success: function (data) { console.log("handling success"); }, fail: function (data, code) { console.log("handling fail, code = " + code); } }) } }) }, editImage(){ var that = this; image.editImage({ uri: that.photoSaveUri, success: function (data) { console.log(data.uri); that.photoUri = data.uri; that.photoSaveUri = data.uri; }, fail: function (data, code) { console.log('handling fail, code = ' + code); } }) }, openPhoto(){ var that = this; media.pickFile({ success: function (data) { console.log('handling success: ' + data.uri); that.photoSaveUri=data.uri; that.photoUri = data.uri; }, fail: function (data) { console.log('handling fail: code' + data.code); } }) }, } script>
回复

使用道具 举报

8

主题

174

帖子

910

积分

2019-8-1 18:05:38 显示全部楼层
图片地址应该是本地地址模式,如果是线上地址。你的 给转一下 。 uri: 'internal://tmp/abc.jpg', 这种模式才能存
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册