Upload Image using web service in php
-> First check for all valid parameter which you are passing
Here is my code for checking valid request
if(isset($_REQUEST["uploadMediaRequest"]) && trim($_REQUEST["uploadMediaRequest"]) != '')
-> i am passing 3 parameters
1) media name
2) type
3) userId or name
$Path= your path + your media name
like
$mediaPath= "upload/chat/".$username."/".$mediaType."/";
if (!file_exists($mediaPath)) {
$oldmask = umask(0);
mkdir($mediaPath, 0777, TRUE);
umask($oldmask);
}
if(is_uploaded_file($_FILES['mediaFile']['tmp_name'])) {
//print_r( $_FILES['videoFile']);echo "filename";
$dest= $_FILES['mediaFile'] ['name'];
move_uploaded_file ($_FILES['mediaFile'] ['tmp_name'], "$mediaPath/$dest");
$resultArray['status']= 'Success';
$resultArray['msg']='Media Uploaded Successfully.';
$resultArray['mediaPath']=$mediaPath."/".$dest;
$resultArray['mediaName']=$mediaName;
die(json_encode($resultArray));
}
it's simple to add or upload image using we bservice in php
Comments
Post a Comment