How can I upload file (images) one by one in a sequential manner in the background in Ionic 3?
up vote
0
down vote
favorite
I read this blog and found out about the file Transfer plugin. They used it to send a file(image) to the server. I want to send multiple file to a server one by one in a sequential order.
public uploadImage()
// Destination URL
var url = "http://yoururl/upload.php";
// File for Upload
var targetPath = this.pathForImage(this.lastImage);
// File name only
var filename = this.lastImage;
var options =
fileKey: "file",
fileName: filename,
chunkedMode: false,
mimeType: "multipart/form-data",
params : 'fileName': filename
;
const fileTransfer: TransferObject = this.transfer.create();
this.loading = this.loadingCtrl.create(
content: 'Uploading...',
);
this.loading.present();
// Use the FileTransfer to upload the image
fileTransfer.upload(targetPath, url, options).then(data =>
this.loading.dismissAll()
this.presentToast('Image succesful uploaded.');
, err =>
this.loading.dismissAll()
this.presentToast('Error while uploading file.');
);
How can I call this code in a sequential manner, so that when one transfer finishes, another starts?
typescript ionic3
add a comment |
up vote
0
down vote
favorite
I read this blog and found out about the file Transfer plugin. They used it to send a file(image) to the server. I want to send multiple file to a server one by one in a sequential order.
public uploadImage()
// Destination URL
var url = "http://yoururl/upload.php";
// File for Upload
var targetPath = this.pathForImage(this.lastImage);
// File name only
var filename = this.lastImage;
var options =
fileKey: "file",
fileName: filename,
chunkedMode: false,
mimeType: "multipart/form-data",
params : 'fileName': filename
;
const fileTransfer: TransferObject = this.transfer.create();
this.loading = this.loadingCtrl.create(
content: 'Uploading...',
);
this.loading.present();
// Use the FileTransfer to upload the image
fileTransfer.upload(targetPath, url, options).then(data =>
this.loading.dismissAll()
this.presentToast('Image succesful uploaded.');
, err =>
this.loading.dismissAll()
this.presentToast('Error while uploading file.');
);
How can I call this code in a sequential manner, so that when one transfer finishes, another starts?
typescript ionic3
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I read this blog and found out about the file Transfer plugin. They used it to send a file(image) to the server. I want to send multiple file to a server one by one in a sequential order.
public uploadImage()
// Destination URL
var url = "http://yoururl/upload.php";
// File for Upload
var targetPath = this.pathForImage(this.lastImage);
// File name only
var filename = this.lastImage;
var options =
fileKey: "file",
fileName: filename,
chunkedMode: false,
mimeType: "multipart/form-data",
params : 'fileName': filename
;
const fileTransfer: TransferObject = this.transfer.create();
this.loading = this.loadingCtrl.create(
content: 'Uploading...',
);
this.loading.present();
// Use the FileTransfer to upload the image
fileTransfer.upload(targetPath, url, options).then(data =>
this.loading.dismissAll()
this.presentToast('Image succesful uploaded.');
, err =>
this.loading.dismissAll()
this.presentToast('Error while uploading file.');
);
How can I call this code in a sequential manner, so that when one transfer finishes, another starts?
typescript ionic3
I read this blog and found out about the file Transfer plugin. They used it to send a file(image) to the server. I want to send multiple file to a server one by one in a sequential order.
public uploadImage()
// Destination URL
var url = "http://yoururl/upload.php";
// File for Upload
var targetPath = this.pathForImage(this.lastImage);
// File name only
var filename = this.lastImage;
var options =
fileKey: "file",
fileName: filename,
chunkedMode: false,
mimeType: "multipart/form-data",
params : 'fileName': filename
;
const fileTransfer: TransferObject = this.transfer.create();
this.loading = this.loadingCtrl.create(
content: 'Uploading...',
);
this.loading.present();
// Use the FileTransfer to upload the image
fileTransfer.upload(targetPath, url, options).then(data =>
this.loading.dismissAll()
this.presentToast('Image succesful uploaded.');
, err =>
this.loading.dismissAll()
this.presentToast('Error while uploading file.');
);
How can I call this code in a sequential manner, so that when one transfer finishes, another starts?
public uploadImage()
// Destination URL
var url = "http://yoururl/upload.php";
// File for Upload
var targetPath = this.pathForImage(this.lastImage);
// File name only
var filename = this.lastImage;
var options =
fileKey: "file",
fileName: filename,
chunkedMode: false,
mimeType: "multipart/form-data",
params : 'fileName': filename
;
const fileTransfer: TransferObject = this.transfer.create();
this.loading = this.loadingCtrl.create(
content: 'Uploading...',
);
this.loading.present();
// Use the FileTransfer to upload the image
fileTransfer.upload(targetPath, url, options).then(data =>
this.loading.dismissAll()
this.presentToast('Image succesful uploaded.');
, err =>
this.loading.dismissAll()
this.presentToast('Error while uploading file.');
);
public uploadImage()
// Destination URL
var url = "http://yoururl/upload.php";
// File for Upload
var targetPath = this.pathForImage(this.lastImage);
// File name only
var filename = this.lastImage;
var options =
fileKey: "file",
fileName: filename,
chunkedMode: false,
mimeType: "multipart/form-data",
params : 'fileName': filename
;
const fileTransfer: TransferObject = this.transfer.create();
this.loading = this.loadingCtrl.create(
content: 'Uploading...',
);
this.loading.present();
// Use the FileTransfer to upload the image
fileTransfer.upload(targetPath, url, options).then(data =>
this.loading.dismissAll()
this.presentToast('Image succesful uploaded.');
, err =>
this.loading.dismissAll()
this.presentToast('Error while uploading file.');
);
typescript ionic3
typescript ionic3
asked Nov 10 at 6:50
stormblessed
188
188
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
You don't need cordova-plugin-file-transfer plugin to transfer files. You can achieve this using XMLHttpRequest Native Browser API.
Below URL explains the various ways, we are transfer files to backend using XMLHTTPRequest API.
https://cordova.apache.org/blog/2017/10/18/from-filetransfer-to-xhr2.html
add a comment |
up vote
0
down vote
I'm going to assume that you have an action like a button click that triggers the upload.
- Maintain a JSON array. Each individual item containing data that you need for
the upload such as file name, file locations, destination url. - On every click of the upload button, push another item into this array.
- Run a loop through the JSON array. For every item, call the upload
function. All data that you need for the upload, already exists in
the array item. - Once the upload is successful, remove that item from
the array.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You don't need cordova-plugin-file-transfer plugin to transfer files. You can achieve this using XMLHttpRequest Native Browser API.
Below URL explains the various ways, we are transfer files to backend using XMLHTTPRequest API.
https://cordova.apache.org/blog/2017/10/18/from-filetransfer-to-xhr2.html
add a comment |
up vote
0
down vote
You don't need cordova-plugin-file-transfer plugin to transfer files. You can achieve this using XMLHttpRequest Native Browser API.
Below URL explains the various ways, we are transfer files to backend using XMLHTTPRequest API.
https://cordova.apache.org/blog/2017/10/18/from-filetransfer-to-xhr2.html
add a comment |
up vote
0
down vote
up vote
0
down vote
You don't need cordova-plugin-file-transfer plugin to transfer files. You can achieve this using XMLHttpRequest Native Browser API.
Below URL explains the various ways, we are transfer files to backend using XMLHTTPRequest API.
https://cordova.apache.org/blog/2017/10/18/from-filetransfer-to-xhr2.html
You don't need cordova-plugin-file-transfer plugin to transfer files. You can achieve this using XMLHttpRequest Native Browser API.
Below URL explains the various ways, we are transfer files to backend using XMLHTTPRequest API.
https://cordova.apache.org/blog/2017/10/18/from-filetransfer-to-xhr2.html
answered Nov 10 at 7:54
Suresh Kumar Ariya
4,0551215
4,0551215
add a comment |
add a comment |
up vote
0
down vote
I'm going to assume that you have an action like a button click that triggers the upload.
- Maintain a JSON array. Each individual item containing data that you need for
the upload such as file name, file locations, destination url. - On every click of the upload button, push another item into this array.
- Run a loop through the JSON array. For every item, call the upload
function. All data that you need for the upload, already exists in
the array item. - Once the upload is successful, remove that item from
the array.
add a comment |
up vote
0
down vote
I'm going to assume that you have an action like a button click that triggers the upload.
- Maintain a JSON array. Each individual item containing data that you need for
the upload such as file name, file locations, destination url. - On every click of the upload button, push another item into this array.
- Run a loop through the JSON array. For every item, call the upload
function. All data that you need for the upload, already exists in
the array item. - Once the upload is successful, remove that item from
the array.
add a comment |
up vote
0
down vote
up vote
0
down vote
I'm going to assume that you have an action like a button click that triggers the upload.
- Maintain a JSON array. Each individual item containing data that you need for
the upload such as file name, file locations, destination url. - On every click of the upload button, push another item into this array.
- Run a loop through the JSON array. For every item, call the upload
function. All data that you need for the upload, already exists in
the array item. - Once the upload is successful, remove that item from
the array.
I'm going to assume that you have an action like a button click that triggers the upload.
- Maintain a JSON array. Each individual item containing data that you need for
the upload such as file name, file locations, destination url. - On every click of the upload button, push another item into this array.
- Run a loop through the JSON array. For every item, call the upload
function. All data that you need for the upload, already exists in
the array item. - Once the upload is successful, remove that item from
the array.
answered Nov 10 at 8:05
Delwyn Pinto
1407
1407
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53236680%2fhow-can-i-upload-file-images-one-by-one-in-a-sequential-manner-in-the-backgrou%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown