*
The moose likes Android and the fly likes how to transfer images to ftp server in android Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "how to transfer images to ftp server in android" Watch "how to transfer images to ftp server in android" New topic
Author

how to transfer images to ftp server in android

Suzzane Pinto
Ranch Hand

Joined: Feb 10, 2012
Posts: 213
i am unable to connect to ftp server from andriod phone..a simple java application to upload image to server is running fine...but the same in andriod is not working
please help me....i want to connect to the server using andriod app only


thankyou
Don Ho
Greenhorn

Joined: Mar 07, 2012
Posts: 9

What does logcat say?
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5811
    
    7

And please post the code you are using to do the upload.


JBoss In Action
Andrew Moko
Ranch Hand

Joined: Dec 16, 2011
Posts: 55
We need to view your code.

The java program doing the upload uses a set of libraries/ apis which OBVIOUSLY don't work in android.

Alternatively, fire-up another file upload app (with startActivity) and receive the response in your logic..
Ben Alex Barreto
Greenhorn

Joined: May 10, 2011
Posts: 15

There are several things that could be causing that. Can we see your code? Make sure you set the right permissions in the manifest, such as internet access for example.


-ben
Suzzane Pinto
Ranch Hand

Joined: Feb 10, 2012
Posts: 213
thankyou for the reply,

i am using andriod 2.1,i have posted my code here
jar i have used is:(org.apache.commons.net_2.0.0.v200905272248.jar)
i have also given the internet permission in manifest file.
please see through the code and help because iam unsuccessful to do this since long

1.mainactivity





2.filetransfer class which is called inside mainactivity
Suzzane Pinto
Ranch Hand

Joined: Feb 10, 2012
Posts: 213
my logcat says:



unable to get that..please help
i am trying to send images from my sdcard to the ftp server..
Is this problem only in emulator??
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Caused by: java.lang.ClassNotFoundException: myapp.test.AndriodTestActivity

Does your app have such a class? The code you posted doesn't.
Don Ho
Greenhorn

Joined: Mar 07, 2012
Posts: 9

Could you also post your AndroidManifest.xml?
Suzzane Pinto
Ranch Hand

Joined: Feb 10, 2012
Posts: 213
dat log cat i posted was different.sory for wrong post..
please see the code and tell me what could be wrong.is this problem of version or emulator?
AndriodManifest.xml

Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
What problem? Is there an exception? If so, post the logcat output. If there's no exception, tell us what the code does right now, and how that differs from what you expected it to do.
Suzzane Pinto
Ranch Hand

Joined: Feb 10, 2012
Posts: 213
the log cat shows



i want to send the image i select from the sdcard to the ftp server i mentioned.
the problem is the image is not uploaded to the server.
i am running on android version 4.0.3


please suggest
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1447
    
    6

Look at the error log, it says could not connect to host 67.15.35.194.


Swastik
Suzzane Pinto
Ranch Hand

Joined: Feb 10, 2012
Posts: 213
can you tell what might be the reason..??
is something wrong in the coding?

iam unable to resolve for a while now
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
It's a network problem. Can you ping that host from the device?
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1447
    
    6

As Tim has said it's a network issue, and port 8080 is typically a http port. Try to connect using the default ftp port.
Suzzane Pinto
Ranch Hand

Joined: Feb 10, 2012
Posts: 213
how to ping on a virtual device?

Suzzane Pinto
Ranch Hand

Joined: Feb 10, 2012
Posts: 213
i changed the port to 21 now still it is not working..
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1447
    
    6

Does the error log say same?
Suzzane Pinto
Ranch Hand

Joined: Feb 10, 2012
Posts: 213
log cat says...

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37879
    
  22
I hope the password you quoted earlier is a dummy password; if no you ought to go back and change the post.
Please don’t post long lines in code tags; I have had to edit your stack traces so they are legible without too much left and right scrolling.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
suzzane pinto wrote:how to ping on a virtual device?

There are any number of Ping apps in the Android Market; some of them are bound to be available as .apk files from their developers in case you don't have access to the Android Market.
Suzzane Pinto
Ranch Hand

Joined: Feb 10, 2012
Posts: 213
unable to get the exception in the logcat?
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1447
    
    6

print a stack trace, this might give a better explanation of the cause
Suzzane Pinto
Ranch Hand

Joined: Feb 10, 2012
Posts: 213
now dat i have used another piece of code my image is getting uploaded to server but not clearly,image is not clear

the code i used are
1.MainActivity



2.ProgressInputStream





logcat says:







please suggest

Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
So which object is null?
Suzzane Pinto
Ranch Hand

Joined: Feb 10, 2012
Posts: 213
m not getting it.....
Andrew Moko
Ranch Hand

Joined: Dec 16, 2011
Posts: 55
at com.myapp.test.ProgressInputStream.sendLong(ProgressInputStream.java:76)
Andrew Moko
Ranch Hand

Joined: Dec 16, 2011
Posts: 55
I don't see the Handler progressHandler in the MainActivity class being initialized. Learn to read and follow through the error stack messages.
Suzzane Pinto
Ranch Hand

Joined: Feb 10, 2012
Posts: 213
now i am able to uplaod images from emulator,but while i run in my mobile device the image is not uploaded...
i recognized that the problem is in getting the absolute path of image before uploading....can you tell me hw to get the image from relative path???
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
This should help: http://developer.android.com/guide/topics/data/data-storage.html#filesExternal
Suzzane Pinto
Ranch Hand

Joined: Feb 10, 2012
Posts: 213
my problem is he app is running fine on virtual device but not in the actual device.
what might be the problem???
when i run from my avd it takes image from the sdcard n then send to server. but in mobile it allows to select from its sdcard and when selected it doesnt upload


any idea why is it so??
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1447
    
    6

Does the device has a proper network connectivity?
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
At which step of the code does the execution start to differ on the real device?
Suzzane Pinto
Ranch Hand

Joined: Feb 10, 2012
Posts: 213
nw it is running from device also i just used following code



now i observed that...images from mobile are loaded incompltly(half image)...whereas from avd upto image sized upto 7b where loaded successfully
is size a problem or something else?

Suzzane Pinto
Ranch Hand

Joined: Feb 10, 2012
Posts: 213
can anyone reply to my post...
will adding progress bar solve my problem of loading incomplete img.....
what can be done??
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
A progress bar is just for providing user feedback; it has no bearing on the actual operation.

What about the question I asked earlier?
Suzzane Pinto
Ranch Hand

Joined: Feb 10, 2012
Posts: 213
Actually i observed later that both from the avd and the mobile images greater than 7kb are not getting uploaded...
i need some solution over that..
Suzzane Pinto
Ranch Hand

Joined: Feb 10, 2012
Posts: 213
will creating a diff thread solve my problem?? may be the UI thread is not taking load....
please correct if i am wrong and do suggest something
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Lengthy operations should definitely not be run in the UI thread. That's what AsyncTask is for: http://developer.android.com/resources/articles/painless-threading.html, http://mobileorchard.com/android-app-developmentthreading-part-2-async-tasks/
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to transfer images to ftp server in android
 
Similar Threads
Is it a good desicion to learn Andriod
Is andriod an open source?
Is there any certification course in Andriod ?
how to write ftp code in android
Does Android Support SVG ?