-1
這是我的web服務,這是從android到php服務器的圖像上傳。我在Advance Rest Client中運行此服務,但每次都會發生未定義的索引錯誤。未定義的索引,而圖像上傳在PHP
這是我的PHP文件:
<?php
session_start();
include('classes/mainclass.php');
header('Content-type: application/json; charset=utf-8');
$CustomHeaders = apache_request_headers();
$category=array();
$main_cat = $_POST['main_cat'];
$sub_cat = $_POST['sub_cat'];
$content_name = $_POST['content_name'];
$address=$_POST['address'];
$contact=$_POST['contact'];
$website=$_POST['website'];
$email=$_POST['email'];
$additional=$_POST['additional'];
//$imgurl=$_POST['imageurl'];
$dataObj = new UserClass();
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
$imageUrl = $target_dir.basename($_FILES["fileToUpload"]["name"]);
$result1 = $dataObj->requestcontent($main_cat,$sub_cat,$content_name,$address,$contact,$website,$email,$additional,$imageUrl);
if($result1)
{
ResponseClass::ResponseMessage("1","Content Request Submitted","True");
}
else
{
ResponseClass::ResponseMessage("2","Content Request Not Submitted","False");
}
} else {
echo "Sorry, there was an error uploading your file.";
}
?>
請確保您的請求在發佈 –
是您的請求內容類型json或鍵值? –
請求在post @ B.Desai –