Best Android Studio Tutorial on How to Upload Image/File to Server (Part 2)

Best Android Studio Tutorial on How to Upload Image/File to Server (Part 2)

Oum Saokosal

8 лет назад

45,406 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@pearrose6098
@pearrose6098 - 03.05.2020 17:49

can you please tell me how to send txt file

Ответить
@mengsreakea7714
@mengsreakea7714 - 18.05.2019 05:57

hello , could you make videos upload multi-images to server.

Ответить
@prashantbhandari9499
@prashantbhandari9499 - 20.02.2019 13:14

It's not working now

Ответить
@poloalo1
@poloalo1 - 14.01.2019 20:41

Hey bro, great video...can we send some text along with this as well..and how(php changes and android changes)?

Ответить
@MDF4072
@MDF4072 - 18.11.2018 07:19

task.execute is not showing in my library? please help

Ответить
@cigana16
@cigana16 - 27.04.2018 17:23

Olá, estou realizando uma atividade na qual preciso que o app faça a captura de 3 imagens, e envie para o banco, essas imagens precisam ir como String ( ou seja, converter a imagem em base64), o problema é que a resolução está saindo que nem do minecraft U-u'

fiz o seguinte :

Converto em Array de bytes

public byte[] convertImageViewToByteArray(Bitmap image) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.JPEG, 100, stream);
return stream.toByteArray()
}
e quando vou salvar a imagem armazeno assim :

img3.setImageBitmap(bitmap2);
Bitmap bit3 = Bitmap.createScaledBitmap(bitmap2, 800, 700, false);
byte[] byteArray3 = convertImageViewToByteArray(bit3);
encodedImage = Base64.encodeToString(byteArray3, Base64.DEFAULT);
imagem.setTerceiraFoto(encodedImage);

Ответить
@SirajulIslam-hd8nc
@SirajulIslam-hd8nc - 23.04.2018 20:51

How can I upload pdf not image? Is it possible?. Thank you.

Ответить
@mir8178
@mir8178 - 18.04.2018 03:18

Hi Oum, if I want to add text in paragraph form to upload along with an image (same as in video), what should I do to do it?

Ответить
@Sport-word
@Sport-word - 02.04.2018 15:51

please make a tutorial how to save the image into the database

Ответить
@jakefuentes7019
@jakefuentes7019 - 21.03.2018 10:25

what is look like on the mysql database?

Ответить
@Jumanto14XyZ
@Jumanto14XyZ - 09.03.2018 05:16

why when taking photos from the camera the result is reversed ?

Ответить
@camiloandresibarrayepes3803
@camiloandresibarrayepes3803 - 05.03.2018 06:51

Hi, when I take a photo and press the send button, and after show the load bar, say error while uploading, but when I check in my folder upload the picture is there, what can i do? thanks

Ответить
@drstephenzulujr8055
@drstephenzulujr8055 - 01.03.2018 15:29

hi am reciveing this erro when i try to upload an image.and the camera isnt working its just runnung the catch exception



E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.zulu.upcamera, PID: 4740
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=22131, result=-1, data=Intent { dat=content://media/external/images/media/35 }} to activity {com.example.zulu.upcamera/com.example.zulu.upcamera.MainActivity}: java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/images/media/35 from pid=4740, uid=10075 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
at android.app.ActivityThread.deliverResults(ActivityThread.java:4089)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4132)
at android.app.ActivityThread.-wrap20(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1533)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/images/media/35 from pid=4740, uid=10075 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
at android.os.Parcel.readException(Parcel.java:1684)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:421)
at android.content.ContentResolver.query(ContentResolver.java:532)
at android.content.ContentResolver.query(ContentResolver.java:474)
at com.kosalgeek.android.photoutil.RealPathUtil.getDataColumn(RealPathUtil.java:131)
at com.kosalgeek.android.photoutil.RealPathUtil.getRealPathFromURI_API19(RealPathUtil.java:67)
at com.kosalgeek.android.photoutil.GalleryPhoto.getPath(GalleryPhoto.java:49)
at com.example.zulu.upcamera.MainActivity.onActivityResult(MainActivity.java:112)
at android.app.Activity.dispatchActivityResult(Activity.java:6932)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4085)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4132) 
at android.app.ActivityThread.-wrap20(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1533) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6119) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

Ответить
@mateusarruda23
@mateusarruda23 - 03.02.2018 22:51

Thank you so musch! Your tutorials helped me a lot on my final paper for college!

Ответить
@programerbangka3709
@programerbangka3709 - 02.01.2018 18:50

subcribe me develovers
its very helpful

Ответить
@wavetv1926
@wavetv1926 - 26.12.2017 14:55

Could not find class 'anCould not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
droid.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering


What's this error?. Someone please help me.

Ответить
@Kdb.1994
@Kdb.1994 - 08.12.2017 15:07

Hi sir, i followed your code but it always be "error while uploading" (using linux server) and no error message on my android monitor. Any solution?

Ответить
@vtubegallery3621
@vtubegallery3621 - 10.11.2017 16:59

can you tell me ,chat back up like a whatsapp. need options:- backup to google drive,account, include video... cane you tell me the source code?

Ответить
@Jumanto14XyZ
@Jumanto14XyZ - 19.10.2017 06:21

upload from gallery size resolution 2560*1920, why cannot ? please help . thanks

Ответить
@khurriazafar4441
@khurriazafar4441 - 21.09.2017 12:48

It is not uploading Image, when i debug it, it is saying size is zero..
postData.put("image",encodedImage); // postData size=0;

Ответить
@widimantoine6997
@widimantoine6997 - 11.09.2017 20:04

saving my day Sir ... Gratitude

Ответить
@sadbeing7208
@sadbeing7208 - 25.08.2017 20:41

Thank you very much

Ответить
@cjbringino
@cjbringino - 20.08.2017 18:14

Hi Oum Saokosal... Will you try creating Upload Video to server? :P that would be great!! Thanks in advance!

Ответить
@BradleyNing
@BradleyNing - 11.08.2017 18:12

The code is the same as part1 which has not including the upload part? Please have double check, thanks!

Ответить
@cjbringino
@cjbringino - 26.07.2017 17:57

Thank you Oum! it helped me a lot.

But there's 1 problem though... In some devices I cannot upload a captured image. :( how do I fix it for all devices??

Ответить
@areebashaikh4950
@areebashaikh4950 - 13.07.2017 21:33

Can i Upload File of any type with this ?

Ответить
@HildaFlores777
@HildaFlores777 - 28.06.2017 21:09

Hello!! I have an Apache Tomcat server and I'm implementing this code. I get the message that everything was successful but when I go to the folder is empty.

I do not get any exceptions, nor any error messages, I do not know what else I could do, because I have already reviewed every detail and I'm doing the same as you.

Ответить
@davidabel9759
@davidabel9759 - 16.06.2017 07:41

thank you for this, i am trying to build an app that users can watch video from it, i want to be able to upload videos from my gallery to users to watch. will this video perform the same function for my app?

Ответить
@kashifkhan8218
@kashifkhan8218 - 09.06.2017 08:23

Hi Sir, i have tried this code every thing is working fine except when i try to upload the image to server its giving an exception of " can not connect to server " please guide me why is so happening and what should i do for proper execution

Ответить
@TheKobeyaoming01
@TheKobeyaoming01 - 03.06.2017 15:55

Thank you Oum.Your video just help me solved my most headache problem for my app

Ответить
@dsouchon
@dsouchon - 25.05.2017 12:16

hi oum. i am getting EACCES permission denied error when debugging on my Huawei P9 Lite phone.

Ответить
@sindhugaster9063
@sindhugaster9063 - 22.05.2017 15:23

I am getting this error when i added GenAsync.jar file--Error:Unexpected lock protocol found in lock file. Expected 3, found 0.

Ответить
@sagaroffice8648
@sagaroffice8648 - 18.05.2017 15:14

where i find complete code

Ответить
@basicknowledge676
@basicknowledge676 - 09.05.2017 16:54

hello teacher. with your lib i use a API 23 it not error. but it not work. teacher can you help to guide to solution this ?

Ответить
@kaushalmarathe5183
@kaushalmarathe5183 - 09.05.2017 09:05

how to Upload Image Using PHP MySQL and Display Images in ListView in Android?

Ответить
@user-dd1nq1kg5b
@user-dd1nq1kg5b - 06.05.2017 05:52

sir, i have a question that it finish everything and when i open the upload folder i can see a pic.jpeg but no content.why it happen?

Ответить
@kajalgaikwad1093
@kajalgaikwad1093 - 28.04.2017 12:26

Sir, code is working fine for uploading images upto size 200 kb but when i upload image that is having size more than 200 kb it gives me error. what should I do??

Ответить
@jell884
@jell884 - 26.04.2017 11:14

I can't upload image to server. actually already copy paste upload.php from your video. And i want to ask, how to delete image if user delete picture from device, it can be automatic deleted to from server. Please explain. Thanks.

Ответить
@raghavendradb6495
@raghavendradb6495 - 18.04.2017 07:53

My app is not working it is showing server error what should i do??

Ответить
@bourgeis
@bourgeis - 07.04.2017 00:38

Hi, thank you for this tutorial.
i like it so much.
But one more question, how to retrieve them in my application, maybe in a gridview or a listview?
thank you so much.

Ответить
@danielzamarripa3335
@danielzamarripa3335 - 30.03.2017 22:46

The result base64 code cant be decoded as the original image, there is a problem with the base64, or a reason of why it can't be decoded
In the log monitor send the bad base-64 error
Anyway it is a excellent tutorial

Ответить
@sidehustler6729
@sidehustler6729 - 27.03.2017 07:45

upload an image to a server automatically when wifi or another network available.I know I have to use Picasa but how can I use it please help me out.

Ответить
@zuenirclaudio4941
@zuenirclaudio4941 - 22.03.2017 18:14

Hello Sir,
Awesome tutorial, thank you..

How can i, retrieve the image from data base? please help me.

Ответить
@jashaairylannedayrit6358
@jashaairylannedayrit6358 - 05.03.2017 09:46

How can i rename the images base on the inputed text on the textfield before uploading it to the database server

Ответить
@jairvasquez1719
@jairvasquez1719 - 28.02.2017 19:46

Because the images are stored on the server horizontally?

Ответить
@MejiMaru
@MejiMaru - 28.02.2017 16:35

Hello Sir,
Awesome tutorial, thank you...

Would you update please, PhotoUtil libs, It can not run no Nougat 7.1

Error output :

android.os.FileUriExposedException: file:///storage/emulated/0/Pictures/JPEG_20170228_202422_1345978128.jpg exposed beyond app through ClipData.Item.getUri()

Ответить
@chaitanyapinapaka3885
@chaitanyapinapaka3885 - 26.02.2017 11:12

Attempt to invoke virtual method 'boolean android.graphics.Bitmap.compress(android.graphics.Bitmap$CompressFormat, int, java.io.OutputStream)' on a null object reference
at com.kosalgeek.android.photoutil.ImageBase64.encode(ImageBase64.java:15)
Help me out
thanks in advance

Ответить
@JLAEZI
@JLAEZI - 16.02.2017 16:46

four method don't accept EachExceptionsHandler in fragment

Ответить