2014-10-09 115 views
0

問題是圖像未移動到UPLOAD_DIR路徑,但該文件的路徑已成功插入服務器。我想將圖像文件保存到服務器文件夾並將其路徑保存到mysql

<?php 
$con=require_once("connection.php"); 

define('UPLOAD_DIR', 'http://hpms.hostei.com/images/'); 

$image= $_REQUEST['image'];    //byte image data received 
$image = str_replace('data:image/png;base64,', '', $image); 
$image = str_replace(' ', '+', $image); 
$data = base64_decode($image); 
$file = UPLOAD_DIR . uniqid() . '.png'; 
$success = file_put_contents($file, $data);// 

print $success ? $file : 'Unable to save the file.'; 


$code=0; 
if($r=mysql_query("insert into images values('','$file')")) 
{ 
$code=1; 
} 


print(json_encode($code)); 

mysql_close(); 
?> 

回答

0

嗨AWAIS汗特區,

You can use the $_FILES server variable. $_REQUEST is used for GET and POST both method 

but you are uploading images i have also this problem and solved with this type. you can 

create post method from any mobile device then save it into folder using 

move_uploaded_file() if any query then tell me, Thanks Hiren kubavat. 
+0

親愛西仁kubavat由$ _REQUEST我是來自機器人接收字節的圖像數據。 – 2014-10-09 13:56:38

相關問題