简体   繁体   English

如何使用PHP将图像上传到我的远程服务器?

[英]How to upload images into my remote server with PHP?

I have an android app, that connectos to the remote database with PHP+json 我有一个Android应用程序,用PHP + json连接到远程数据库

but now, i have to store photos of the users on the remote server. 但现在,我必须在远程服务器上存储用户的照片。 I need to do it storing the URL of the uploaded photo in a row of the USER TABLE. 我需要将上传的照片的URL存储在USER TABLE的一行中。 That is not the problem. 那不是问题。 The problem is that i have not idea about with a given path of a photo, how to upload it into a dir of the remote server of my app? 问题是我不知道照片的给定路径,如何将其上传到我的应用程序的远程服务器的目录?

as i know, i need two things, a function that connects with a PHP and gives to the PHP the photo, and a PHP that receives the photo and uploads it into a dir of the remote database. 据我所知,我需要两件事,一个与PHP连接并向PHP提供照片的函数,以及一个接收照片并将其上传到远程数据库目录的PHP。

Well....¿can someone help me to do it? 好吧……有人可以帮我做吗?

I checked a lot of tutorials of doing this with PHP but i can't find a easy one that how to do it with android+php+mysql, all i am finding is too hard for me. 我检查了很多使用PHP进行此操作的教程,但我找不到一个简单的方法来使用android + php + mysql,这对我来说太难了。

can someone give me the code i need to do it? 有人可以给我我需要做的代码吗?

thanks 谢谢

EDIT: 编辑:

there does not exist a simple function and a simple PHP code that does it? 有没有一个简单的函数和一个简单的PHP代码呢? Simple ones, the examples you are giving me are very hard for my skills with this and i can't apply to my android app and my remote server 简单的,你给我的例子对我的技能很难,我无法应用到我的Android应用程序和我的远程服务器

For the PHP side: http://it.php.net/manual/en/features.file-upload.php (there are a lot of sample) 对于PHP方面: http//it.php.net/manual/en/features.file-upload.php (有很多样本)

For the Android side: this article explains hot to use DefaultHttpClient for make and upload via HTTP 对于Android方面: 本文介绍了如何使用DefaultHttpClient通过HTTP进行制作和上传

For the Android part, its just straight Java, and there are loads of examples of using HttpClient to perform file uploads. 对于Android部分,它只是简单的Java,并且有大量使用HttpClient执行文件上传的示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM