Android - Display all images from server folder using PHP in GridView -
i trying capture image or record video using camera , upload server. on server side, used php language read file , moved particular location. want display these images stored server. please me.
this upload image php script
<?php // path move uploaded files $target_path = "uploads/"; // array final json respone $response = array(); // getting server ip address $server_ip = gethostbyname(gethostname()); // final file url being uploaded $file_upload_url = 'http://' . $server_ip . '/' . 'androidfileupload' . '/' . $target_path; if (isset($_files['image']['name'])) { $target_path = $target_path . basename($_files['image']['name']); // reading other post parameters $email = isset($_post['email']) ? $_post['email'] : ''; $website = isset($_post['website']) ? $_post['website'] : ''; $response['file_name'] = basename($_files['image']['name']); $response['email'] = $email; $response['website'] = $website; try { // throws exception incase file not being moved if (!move_uploaded_file($_files['image']['tmp_name'], $target_path)) { // make error flag true $response['error'] = true; $response['message'] = 'could not move file!'; } // file uploaded $response['message'] = 'file uploaded successfully!'; $response['error'] = false; $response['file_path'] = $file_upload_url . basename($_files['image']['name']); } catch (exception $e) { // exception occurred. make error flag true $response['error'] = true; $response['message'] = $e->getmessage(); } } else { // file parameter missing $response['error'] = true; $response['message'] = 'not received file!f'; } // echo final json response client echo json_encode($response); ?>
upload camera image:
i want display theses images synchronised when upload images again.
config.java
public class config { // file upload url (replace ip server address) public static final string file_upload_url = "http://wangjian.site90.net/androidfileupload/fileupload.php"; // directory name store captured images , videos public static final string image_directory_name = "android file upload";
i'm newbie @ stuff appreciated. much! , upload more details if needed.
have api endpoint return urls of images have uploaded , call them app.
like,
public static final string file_download_url = "http://wangjian.site90.net/androidfileupload/getuserphotos.php";
let return json array like,
{ "urls" : [ { "url" : "url of pic 1" }, { "url" : "url of pic 2" }, .. ] }
have custom gridadpater
imageview
in it. use libraries picasso load images url gridview
using custom adapter custom view (here, imageview
).
call api endpoint every time when user on screen you'll able fetch list of uploaded photos , show them everytime.
Comments
Post a Comment