TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sayuj Raghavan
NA
52
6.9k
Webservices in PHP for picture upload
Apr 18 2016 6:37 AM
I am working on android app's web service for picture uploading. So far ,I have attempted to work on with the below code.
<?php
include('db.php');
$jobseeker_id =isset($_POST['JobseekerID']) ? mysql_real_escape_string($_POST['JobseekerID']) : "";
// Get image string posted from Android App
$base=isset($_POST['image']) ? mysql_real_escape_string($_POST['image']) : "";
// Get file name posted from Android App
$filename=isset($_POST['filename']) ? mysql_real_escape_string($_POST['filename']) : "";
echo $base;
// Decode Image
$binary=base64_decode($base);
header('Content-Type: bitmap; charset=utf-8');
//Images will be saved under 'images' folder in the server
chmod("images",777);
$file = fopen('images/'.$filename,'wb');
// Create File
fwrite($file, $binary);
fclose($file);
if($file)
{
$q=mysql_query("UPDATE documents SET crop_pic=' $binary' where user_id='$jobseeker_id'")or die(mysql_error());
$response["ProfilePic"][]= array("Status"=>"1","Message" =>"Profile Pic is uploaded");
echo die(json_encode($response));
}
else
{
$response["ProfilePic"][]= array("Status"=>"0","Message" =>"Profile Pic uploding failure");
}
?>
In the above code, I am not getting the image decoded from the android app successfully, image is getting into the folder ,but the image is not getting displayed perfectly. I doubt its mistake of
base64_decode
function . I am still not able to find why the image is not getting displayed. Hoping for some help to rectify it or point out the logical or syntactical error in the above code.
Reply
Answers (
0
)
How to use array values in Where Clause in MySQL?
Privacy selectors using PHP