我想发布照片并在Alphafire中快速使用php 这是我在php中的代码
if(isset($_POST)){
$user_member = filter_var($_POST['member'] , FILTER_SANITIZE_STRING);
$usersModel = new UsersModel();
if($usersModel->checkUserMemberId($user_member)){
$title = filter_var($_POST['title'] , FILTER_SANITIZE_STRING);
$desc = filter_var($_POST['desc'] , FILTER_SANITIZE_STRING);
$image = isset($_FILES['file']['name']) ? $_FILES['file'] : FALSE;
$Tickits_model = new Tickets_Model();
if($Tickits_model->addNewTickit($title, $desc, $image , $user_member)){
header('HTTP/1.1 200');
header('Content-Type: application/json; charset=UTF-8');
die(json_encode('success'));
}else{
header('HTTP/1.1 400 Bad Request');
header('Content-Type: application/json; charset=UTF-8');
die(json_encode('error'));
}
}
}
这是我的快速代码
func uploadimage() {
var myUrl = "myurl"
myUrl = myUrl.addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed)!
let url = URL(string: myUrl)
let image = isimage.image!
guard let data = image.jpegData(compressionQuality: 0.75) else {
return
}
Alamofire.upload(multipartFormData: { (form) in
form.append(data, withName: "image" ( i try using "file" and same problem) , fileName: "file.jpg", mimeType: "image/jpg")
}, to: url! , encodingCompletion: { result in
switch result {
case .success(let upload, _, _):
upload.responseString
{
response in
print(response)
print(result)
print(response.description)
}
case .failure(let encodingError):
print(encodingError)
}
})
}
这是显示的错误
success(request: 2019-01-12 18:09:27.000943+0300 NFSTORE[6346:2103776] CredStore - performQuery - Error copying matching creds. Error=-25300, query={
class = inet;
"m_Limit" = "m_LimitAll";
ptcl = htps;
"r_Attributes" = 1;
sdmn = "myurl";
srvr = "myurl";
sync = syna;
我尝试将“图像”更改为“文件”,并遇到相同的问题。 我使用Alamofire中的另一种方法和一种上传图像的方法发送其他参数(title-desc-member)。 我不知道这是否正确,但是如果不能给出最好的主意,请