I need to send images from server side to client side.
If I just echo the image data, it's not safe. In the client side, I need to process and use the images (I will use these images with web unity) but I don't want the original images to be exposed.
Any help is appreciated.
Will SSL do what you need?
If you need more (to prevent snooping), check out the http://php.net/manual/en/book.mcrypt.php library: you'll need to find a corresponding decryption function in Unity. Encypt the raw image data (e.g. jpeg or png) and send over the wire; decrypt in Unity and rebuild the image.
Related
I'm creating a PHP web service that saves files to MySql database.
The client side of my application is Android.
What is the proper way to upload a file(image, pdf, etc.) from android and save it to MySql database using PHP?
I'm not looking for codes right now, just wondering how I can do that?
The android can use the base64 to encode the img. Then you create a post http request to your php server.Your php save the base64 code to the mysql.
When you read the img.You can decode base64 to img.
Note:If you encode a img to base64 the base64 code size will bigger then img.
What I have:
I have some images on SDcard, to be sent to a PHP server.
What I want:
I want to encrypt these images before sending to server. There will be a unique key, for every user of application, which will be used for encryption on Android Side and for decryption on PHP server side.
Please guide me how can I do this encryption and how should I send these encrypted Images to server. I can send simple images to a server (using multipart etc). But what should be the way to encrypt and then send the image to server?
I can write you some simple steps to achieve this:
Convert your image into bytes array. Read this
Convert that bytes array into Base64 string. Read this
Encrypt Base64 string using this sample code
Send the encrypted string to your server using ksoap or json
*If you reverse this process on server, you'll get your image back.
Tadaaa! :)
I have an image on a web page constructed like so:
<img src="data:image/png;base64;...." />
The contents of the image come from the user pasting into the browser. My question is how do I then upload the image to the webserver (PHP if that matters).
1) Take the src attribute with javascript (or the data submitted by user)
2) Submit it to the server 'as is' or cut and submit everything after base64; (AJAX or POST, method GET is probably not very suitable here for large images)
3) Decode base64 on server side (everything after base64; if not cutted), save the result as binary - it is an image.
That's it.
ps: just a reminder - by careful with possible code injection. Check the submitted data or somebody will upload encoded php script. Disable php engine in the folder with uploads and verify that the final result is an actual image (with the help of GD library, for example). Even if the script can not run on your server it could be used for malicious requests to other servers with php scripts.
Just post the base 64 encoded text to your server.
You could save it as...
file_put_contents($image, base64_decode($str));
multiple images should be uploaded from iphone to a php server and images will be sent to php server as an http request.
something like this www.ursite.com/event_id=1234qwer&method=upload&data=!##$%^&*&^%$##!!....
data=!##$%^&&^%$##!!&&(&&$$%$#$#GFGF%$4....
it would a random value and it is packet of data[images]. We need to read this raw data using php
how can I do that??
http://pastebin.com/WAp5AV5Y
You shouldn't be sending your data as a GET request, you should be sending it as a multipart POST call. There's plenty of resources about that over the web, SO included. Also check out this page.
On the PHP side you will receive the uploaded files in the $_FILES array just as if the user uploaded the images from a HTML form so you don't need to do anything special to handle an iPhone upload.
I have some good news, and I have some bad news.
The good news is that the image data is just a JPEG, so GD's imagecreatefromstring will do the job nicely to ensure that the data is a valid image.
The bad news is twofold:
The data has come in without the benefit of URL-encoding, so it is surely corrupt.
GET method requests have a relatively small available data size.
You will need to have the data submitted as a POST, properly encoded.
I want to use imgur's API to upload images however I don't want to use my server too much in the act because I'd like to keep bandwidth to a minimum.
The API accepts images in a base64 encoded string or binary.
Also if there's a way to encode images into base64 or binary in javascript that would be really useful to know too
JavaScript security restrictions prevent you from reading a local file and doing anything with it. That will be the reason that you cannot encode a file in Base64 and send it directly to that API.
Does Imgur have an API which accepts a direct file upload?