tags:

views:

45

answers:

2

I am using following tutorial to upload image file to webserver.

and getting file not found exception here.

try {
         File uploadFile = new File(uriString); 

// file path i receive **content:/media/external/images/media/2**

        FileInputStream fis =   this.openFileInput(uploadFile.getName()); // **ERRoR HERE**

        HttpFileUploader htfu = new HttpFileUploader("http://finditnear.sigmatec.com.pk/inbox/send_remote_reply","noparamshere", uploadFile.getName());
        htfu.doStart(fis);
        } 
    catch (FileNotFoundException e) {
        Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
        e.printStackTrace();
        return;
        }

image file exists there but still it giving me error.

Can any one guide me what is the solution?

A: 

Did you add:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

to your AndroidManifest?

Macarse
no i did not :( and second thing i just want to read image and upload so i might need reading permission Right?and thanks for reply.
UMMA
Don't think so. With that you can read and write.
Macarse
+1  A: 

content:/media/external/images/media/2 is incorrect file name, it's a Uri.
So this line

FileInputStream fis =   this.openFileInput(uploadFile.getName());

Should be replaced with

InputStream fis=this.getContentResolver().openInputStream(new Uri(uriString));
Fedor
Uri constructor does not exist.anyways thanks yes i got the answerInputStream fis = this.getContentResolver().openInputStream(Uri.parse(uriString));
UMMA
Right, I didn't build the code just typed :-)
Fedor