【发布时间】:2019-02-10 07:48:37
【问题描述】:
在通过图像选择器裁剪后,我正在尝试使用 ionic 应用程序将图像上传到 php 服务器。图片在其显示的路径中不存在。
有没有办法指定保存裁剪图像的路径?
这是我的代码:
getImage()
{
var options = {
maximumImagesCount: 1,
width: 800,
height: 800,
quality: 80,
};
this.imagePicker.getPictures(options)
.then((results) => {
this.reduceImages(results).then(() => {
this.photos = results;
const fileTransfer: FileTransferObject = this.transfer.create();
let d = new Date();
let time = d.getTime();
let options_f: FileUploadOptions = {
fileKey: 'file',
fileName: this.name + time + '.jpg',
chunkedMode: false,
mimeType: "image/jpg",
};
let url='https://elevather.com/mentor/file_upload.php';
fileTransfer.upload(this.photos, url, options_f)
.then((data) => {
if(data["_body"]=="yes")
this.msg = 'yes';
else
this.msg = 'no';
}, (err) => {
console.log('upload failed!');
});
}, (err) => { });
}, (err) => { });
}
reduceImages(selected_pictures: any) : any{
return selected_pictures.reduce((promise:any, item:any) => {
return promise.then((result) => {
return this.cropService.crop(item, {quality: 80})
.then(cropped_image => console.log('Done'));
});
}, Promise.resolve());
}
我还有其他方法吗?
【问题讨论】:
标签: typescript cordova ionic-framework ionic3 phonegap