Kumar,

I am testing code and there is and error. i am attaching my android
and php server script with logcat. please take a look where i am doing
wrong.

Android Code:

  File file = new File("sdcard/F1.txt");
        try {
                 HttpClient client = new DefaultHttpClient();

              String postURL = "myserver/uploader.php";
              HttpPost post = new HttpPost(postURL);
             FileBody bin = new FileBody(file);
             MultipartEntity reqEntity = new
MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
             reqEntity.addPart("myFile", bin);
             post.setEntity(reqEntity);
             HttpResponse response = client.execute(post);
             HttpEntity resEntity = response.getEntity();
             if (resEntity != null) {
 
Log.i("RESPONSE",EntityUtils.toString(resEntity));
                 }
        } catch (Exception e) {
            e.printStackTrace();
        }

PHP Script:
<?php
// Where the file is going to be placed
$target_path = "uploads";

/* Add the original filename to our target path.
Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['uploadedfile']
['name']);

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'],
$target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']).
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}
?>


And LogCat:
I/ActivityManager(   71): Start proc com.Testuploading for activity
com.Testuploading/.Testuploading: pid=339 uid=10024 gids={3003, 1015}
D/ddm-heap(  339): Got feature list requestD/dalvikvm(  339): GC freed
5735 objects / 366104 bytes in 279ms
D/dalvikvm(  339): GC freed 7091 objects / 454808 bytes in 191msD/
dalvikvm(  339): GC freed 798 objects / 68064 bytes in 191ms
I/dalvikvm-heap(  339): Grow heap (frag case) to 3.885MB for 87396-
byte allocation
D/dalvikvm(  339): GC freed 0 objects / 0 bytes in 230msI/
RESPONSE(  339): <br />
I/RESPONSE(  339): <b>Notice</b>:  Undefined index: uploadedfile in
<b>C:\wamp\www\uploader.php</b> on line <b>7</b><br />
I/RESPONSE(  339): <br />
I/RESPONSE(  339): <b>Notice</b>:  Undefined index: uploadedfile in
<b>C:\wamp\www\uploader.php</b> on line <b>9</b><br />
I/RESPONSE(  339): There was an error uploading the file, please try
again!
W/ActivityManager(   71): Launch timeout has expired, giving up wake
lock!
I/ActivityManager(   71): Displayed activity
com.Testuploading/.Testuploading: 10272 ms (total 10272 ms)
D/dalvikvm(  126): GC freed 660 objects / 34136 bytes in 561ms


Thanks

On Sep 20, 2:11 pm, Kumar Bibek <[email protected]> wrote:
> Again, the same question, Where are you stuck????
>
> -Kumar Bibekhttp://techdroid.kbeanie.com
>
> On Sep 20, 10:57 am, Hotouch <[email protected]> wrote:
>
> > Kumar,
>
> > basically i got code from anddev forum and its for sdk 1.1 but i need
> > complete fresh code for latest SDK. please help me out. thanks
>
> > Regards,
> > David
>
> > On Sep 19, 10:17 pm, Kumar Bibek <[email protected]> wrote:
>
> > > Where are you stuck by the way? And yes, give some details please...
>
> > > -Kumar Bibekhttp://techdroid.kbeanie.com
>
> > > On Sep 19, 6:44 pm, Prakash Iyer <[email protected]> wrote:
>
> > > > Sure. You can find it here,
>
> > > >http://www.catb.org/esr/faqs/smart-questions.html
>
> > > > Will you take fries and a drink with that?
>
> > > > On Sep 19, 2010 9:36 AM, "David Harris" <[email protected]> wrote:
>
> > > > Dear Members,
>
> > > > Please Please help me!!!
>
> > > > I need the java code for sending file from android and then a php code
> > > > to accept that file and store in my server.
>
> > > > I tried lots of code available on internet but have not succeeded :( i
> > > > am using latest Android SDK.
>
> > > > Please provide me with complete code if some one has. I am working on
> > > > this issue from last 14 days and it's still not resolved :(
>
> > > > Regards,
> > > > David
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > > > Groups "Android Developers" group.
> > > > To post to this group, send email to [email protected]
> > > > To unsubscribe from this group, send email to
> > > > [email protected]<android-developers%[email protected]>
> > > > For more options, visit this group 
> > > > athttp://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to