function saveImage() {
uni.getImageInfo({
src: previewImg[0],
success: (info) => {
console.log(info,'info');
copyImage(info.path);
},
fail: (error) => {
console.error('获取图片信息失败', error);
},
});
}
function copyImage(originalPath) {
let lastCommaIndex = originalPath.lastIndexOf('/');
let firstPart = ''
let secondPart=''
if (lastCommaIndex !== -1) {
firstPart = originalPath.slice(0, lastCommaIndex);
secondPart = originalPath.slice(lastCommaIndex + 1);
console.log(firstPart); // 输出: apple,orange
console.log(secondPart); // 输出: banana
} else {
secondPart='temp_image'
console.log("没有找到逗号");
}
const tempPath = uni.env.USER_DATA_PATH + '/'+secondPart; // 临时文件路径
console.log(tempPath,"tempPath");
const file = {path:tempPath}
$singleFileImg('applyment', file).then((bizData) => {
console.log(bizData,"bizData");
})
}
uniapp生成本地服务器图片路径
最新推荐文章于 2024-08-14 15:24:40 发布