How to upload images into my remote server with PHP? - php

I have an android app, that connectos to the remote database with 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. 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.
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.
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? 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

For the Android part, its just straight Java, and there are loads of examples of using HttpClient to perform file uploads.
How to upload a file using Java HttpClient library working with PHP - strange problem
google search

For the PHP side: http://it.php.net/manual/en/features.file-upload.php (there are a lot of sample)
For the Android side: this article explains hot to use DefaultHttpClient for make and upload via HTTP

Related

upload image from android UI to php server side api

i got two questions.
1) i want to upload image into php server and the front end will be android. and i want all processing to be done by php api like checking image and name extension and even error checking .
All the tutorials that i surfed has done in such way that most of the processing is done in android and only for storing uses php api. so any suggestion which supports above requirement will be of great help.
2) $_FILES["fileContents"]["type"] this line in php api is directly used with android uploadimage . i know that it initates file browse option but how to pass parameter value ['fileContents'] from android code.
thanks

How to post images to users' wall (or in folders/albums) on Facebook (2013)

I am using Facebook's PHP SDK. I looked here (official documentation by Facebook) for help. It is not working for me because I am using images hosted externally but if I try to upload files hosted within my server then it works fine.
Is there any new way to do this. Please try to explain both (Posting to feed and to some folder/album). Sorry for this question but others here were of no help to me.
Please suggest any PHP editor that is compatible with Facebook's API. (Auto-completion etc.)
Stack is normally for solving small issues (think using = rather than > in a query) not a complete project.
Have you attempted writing this code yourself, if so what errors is it spitting out? rather than saying it doesn't work.
If the images are stored somewhere out there, you need to download them to your server and upload them to FB. You can't just tell FB an URL of an image, it's not working like this.
In order to upload fotos, you may use the "photo post" Method on the FB API. And it wants the binary data of the image. You may link an input and an output stream to that (what I would prefer using Java since no storage is needed).
Since your code is working with locally hosted images, just encapsulate that part and make the external image an internal one first.

iPhone app-communicating with servers

Ok. I am a bit of a new developer and haven't done much work with networking (in general, not specifically obj-c). Basically, I need to record a file (I have code to do this), then upload it to a server. I've looked at code to upload to servers and it seems that all I need from the server side of things is a html upload page with a php script, which I have. Another option would be ftp/sftp, although this would be harder to implement. The problem is I need to have authentication for the upload, and preferably have a secure (https) upload, with a username and password. I cannot figure out how to do this. I would also need the server to send back a response to the app.
Also, are their any frameworks to make it easier to upload files? I know there was asihttprequest, but that was discontinued...
What would I need to make the server do to have authentication and authenticated uploads, and be able to return data back to the app? Sorry for such a n00by question, but if you could help that would be great.
Thanks
Check out AFNetworking. I really enjoy doing file downloads and uploads using AFNetworking. The FAQ even gives an example on how to upload a file and download a file. All you need server side is a PHP script to handle a POST file upload.

Is the android emulator able to upload files to a server

I cannot find this anywhere. Is the android emulator able to upload files to a web server? I have been testing for the last hour or so and just realized it may not even be possible. Anyone know?
Yes its possible. It's a little complex to post the code but essentially you'd use File class to find which file you want to upload and then use the apache HttpClient library to do the multiform post. Now if you think it won't work because you don't know what interface the user will use to find the file. There is a way to send an Intent to open a file.
Send an Intent for the user to select a file on Android
But the rest is simply writing the code to perform the upload.

Vimeo PHP Upload Directory

I have spent this best part of a week rattling my brain to get this working and I've just come to the conclusion that this is out of my scope. I know this is a rather large ask but I just can't figure it out. :(
Anyway, I am trying to upload some files in a directory on my webserver to Vimeo through a protected php script (I say protected because the script itself will not be accessible from the web) and have that script run via a cron job. The script will only upload to my account.
I have gotten as far as getting a consumer key and consumer secret from vimeo.
I have been attempting to use their documented API demo but that keeps requesting an oauth_token and oauth_token_secret, both of which I don't know how to obtain. I found it quite confusing and unsure if I could adapt it for my requirements. Instead, I googled and found this blog post about transfering files from youtube to vimeo - http://mclear.co.uk/2011/05/27/transfer-videos-from-youtube-to-vimeo/ - I thought I could use it as a building block but I've hit a dead end here also.
To explain the full scale of what I'm trying to achieve:
Video file is created on originating computer - Working
User adds ID3 tags to the file and drops it in a watched folder - Working
Local server sends the file via ftp to the webserver directory - Working
Php script reads the ID3 for the file and uploads it to vimeo - [ID3 Extractor working -Vimeo uploader not working]
Vimeo responds with upload location to script which then connects to our mysql server to add the record - Not working but straightforward to implement once uploader works
Thank you so much in advance for any help you can give.
Richard
I made some progress on this with the php "Transfer Youtube to Vimeo tool" I made
The download at the bottom of the article will get you uploading w/ PHP
The CLI tool is now available and comes with a video tutorial for how to use it.
Credit to #TomNomNom
Please don't contact me RE this I'm not supporting this code it was just hacked together :)

Categories