Community
cancel
Showing results for 
Search instead for 
Did you mean: 
kishan_k_
Beginner
80 Views

How to Upload Image to Server

Jump to solution

Hello friend,

How to upload image to server. i used intel xdk and cordova plugin used.and also used file transfer plugin. i upload image on my android phone ,but image can not upload to server.

below code:

<html>

<head>

<script>

 function getImage() {
 navigator.camera.getPicture(uploadPhoto, function(message) {
 alert('get picture failed');
 }, {
 quality: 100,
 destinationType: navigator.camera.DestinationType.FILE_URI,
 sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY
 });
}

function uploadPhoto(imageURI) {
 var options = new FileUploadOptions();
 options.fileKey = "file";
 options.fileName = imageURI.substr(imageURI.lastIndexOf('/') + 1);
 options.mimeType = "image/jpeg";
 console.log(options.fileName);
 var params = new Object();
 params.value1 = "test";
 params.value2 = "param";
 options.params = params;
 options.chunkedMode = false;

var ft = new FileTransfer();
    console.log(imageURI);
     alert(imageURI);
 ft.upload(imageURI, "http://servername/upload.php", function(result){
     
 console.log(JSON.stringify(result));
 }, function(error){
 console.log(JSON.stringify(error));
 }, options);
 }

</script>

</head>

<body>

<button onclick="getImage()">Upload a Photo</button>

</body>

</html>

Tags (2)
0 Kudos
1 Solution
PaulF_IntelCorp
Employee
80 Views
3 Replies
PaulF_IntelCorp
Employee
81 Views
PaulF_IntelCorp
Employee
80 Views

 kishan k. wrote:

i search my question on google,but google can not find any solution,so please give me for your suggestion

From the Google search that was provided, there are several good articles to use as a reference:

 

PaulF_IntelCorp
Employee
80 Views

kishan k. wrote:

i follow tutorialspoint for file transfer,but this example can not work on my android phone, i am used intel xdk tools,and i put file transfer code on this tools,but it is not working ,so please you write code .

I'm sorry, but we do not have the resources to help you write your Cordova HTML5 application or debug your program issues. We are providing you with the tools to build and debug your app, but we are not able to provide personal debug services. I recommend you search the Internet for solutions to your problem, there are many blogs and posts on Stack Overflow covering how to write Cordova and PhoneGap apps. The Intel XDK creates a standard Cordova application, so solutions for Cordova and PhoneGap will apply to an application written to be built with the Intel XDK.

Reply