2014-02-05 22 views
0
<?php 
include("apiconfig.php"); 
global $api_key; 
foreach($_REQUEST as $k=>$val) 
     { 
      $_REQUEST[$k]=input_clean_string($val); 
     } 
if(isset($_REQUEST['api_key']) && !empty($_REQUEST['api_key']) && $_REQUEST['api_key']==$api_key && isset($_REQUEST['user_id']) && !empty($_REQUEST['user_id']) ){ 
$user_id=$_REQUEST['user_id']; 
$profile_image=file_get_contents('php://input'); 


if ($profile_image) { 

    $sql="UPDATE users SET profile_image='".$profile_image."' WHERE user_id=".$user_id; 
    mysql_query($sql); 
} 
echo $user= get_userdata($user_id); 
}else{ 

echo json_encode(array('errormsg' => 'Invalid access.')); 

} 

這裏我沒有得到profile_image。我將圖像數據以binery格式存儲到表格中(使用blob,我正在存儲數據)。這裏$profile_image爲空如何使用file_get_content獲取圖像數據

回答

0

嘗試使用stream_get_content函數代替file_get_content。如果你獲得資源類型。

$ profile_image = stream_get_content('php:// input');

相關問題