Upload a File to a Remote Server running ASP.NET with Phonegap

7,753 views
Skip to first unread message

cwkhang

unread,
Sep 26, 2011, 11:52:33 PM9/26/11
to phonegap
i've seen this example written for php
http://zacvineyard.com/blog/2011/03/25/upload-a-file-to-a-remote-server-with-phonegap/

just wonder will it work if it was posted to ASP.NET? any example?

Arun Prasad

unread,
Sep 27, 2011, 3:37:07 AM9/27/11
to phon...@googlegroups.com
Check out this question: http://stackoverflow.com/q/7486725

I've used this asp.net c# code to handle an audio file upload from PhoneGap. Hope this helps.

cwkhang

unread,
Sep 28, 2011, 3:12:11 AM9/28/11
to phonegap
FINALLY!! was able to upload image from android to server via asp.net
web service. hope this help someone

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

function uploadPhoto(imageURI) {
var options = new FileUploadOptions();
options.fileKey="recFile";
var imagefilename = Number(new Date())+".jpg";
options.fileName=imagefilename;
options.mimeType="image/jpeg";

var params = new Object();
params.value1 = "test";
params.value2 = "param";

options.params = params;

var ft = new FileTransfer();
ft.upload(imageURI, "http://site.com/WebSite1/
FileUpload.asmx/SaveImage", win, fail, options);
}

function win(r) {
//console.log("Code = " + r.responseCode);
//console.log("Response = " + r.response);
alert("Sent = " + r.bytesSent);
}

function fail(error) {
alert("An error has occurred: Code = " + error.code);
}

my asp.net web service code:
[WebMethod]
public string SaveImage()
{
HttpPostedFile file =
HttpContext.Current.Request.Files["recFile"];
string targetFilePath = "c:\\" + file.FileName;
file.SaveAs(targetFilePath);

return file.FileName.ToString();

Alastair Gilfillan

unread,
Jul 26, 2012, 10:26:13 AM7/26/12
to phon...@googlegroups.com
Isn't there a way to run PHP on Microsoft Windows servers? Just install that package...(or a functional stack)?

Eyal Berman

unread,
Sep 11, 2012, 2:26:53 AM9/11/12
to phon...@googlegroups.com
https://groups.google.com/d/msg/phonegap/xNEj03mz61A/rOcgqunOu0cJ

On Tuesday, July 10, 2012 9:31:32 PM UTC+3, mcclimonth wrote:
Did you ever try to upload an image from an iOS device to a server using ASP.NET?  Could you please post your complete index.html and web service files?

I am using Phonegap code that is almost identical to yours.  I found it on phonegap.com.  My web service code is also almost identical to yours.  I haven't tried Android yet because I am more concerned about getting it to work on iOS. 

Every time I try to upload an image, I get a 404 error (error code 3).  I've already adjusted the whitelist, and I can access my web service when I go to the URL in a browser.

Thanks

naresh

unread,
Sep 12, 2012, 12:51:20 AM9/12/12
to phon...@googlegroups.com

Hi Bogdon,
i am using phonegap with windoesphone7 , HTML and Javascript.
i am facing an issue on ImageSize. 
i uploaded some images into server from my app.
 i am retrieving images also working fine.
issues;
1)if imagesize is >100KB image as not able to invoke my system.for that how can i will do this?
here the my problem is when i uploading image i reduced size by using quality,hight and width .
when i was retrieving  the some images at a time .here i am facing the problem is if total images size are >100KB not displaying.
But lessthan 100KB working fine. For that i am trying to increasing the retrieve images size. how can i will do this?
Could you help to me.
Thanks in Advance.


On Monday, September 10, 2012 5:50:15 PM UTC+5:30, Bogdan wrote:
Hi  mcclimonth,

Check the size of the image sent to server. If it's > 65K then you need to make some changes on the config file.
Good luck!

prabhu kumar thammareddy

unread,
Jun 22, 2017, 3:01:18 PM6/22/17
to phonegap, kha...@gmail.com
Followed the same steps mentioned by you, Getting error "Sent = 'Undefined' " .
Please can you help ! 

jcesarmobile

unread,
Jun 23, 2017, 8:56:59 AM6/23/17
to phonegap, kha...@gmail.com
This is from 2012, the plugin API might have changed in 5 years.
Reply all
Reply to author
Forward
0 new messages