Question by
unity_EDdq8x7gw4afZg · Jan 07, 2019 at 08:21 AM ·
c#errornetworkingapiwebrequest
MultipartFormDataSection not working - Error: 403
This project goal is uploading user image to server so I am trying to test my api with UnityWebRequest and MultipartFormDataSection.
And I found out I am not able to pass values with MultipartFormDataSection but WWWForm is successful to pass values.
This is my Multipart Code:
List<IMultipartFormSection> formData = new List<IMultipartFormSection> ();
formData.Add (new MultipartFormDataSection ("fileName", "i_am_fileName.png"));
formData.Add (new MultipartFormDataSection ("fileName2", "i_am_fileName.png2"));
UnityWebRequest wwwGetURL = UnityWebRequest.Post ("http://www.{myserver}.com/projects/BoLe/api/saveimage.php", formData);
wwwGetURL.chunkedTransfer = false;
yield return wwwGetURL.Send ();
Debug.Log (wwwGetURL.downloadHandler.text);
The Result is :
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /projects/BoLe/api/saveimage.php
on this server.<br />
This is my WWWForm Code
WWWForm formData = new WWWForm ();
formData.AddField ("fileName", "i_am_fileName.png");
formData.AddField ("fileName2", "i_am_fileName.png2");
UnityWebRequest wwwGetURL = UnityWebRequest.Post ("http://www.{myserver}.com/projects/BoLe/api/saveimage.php", formData);
wwwGetURL.chunkedTransfer = false;
yield return wwwGetURL.Send ();
Debug.Log (wwwGetURL.downloadHandler.text);
The Result is :
{"return_code": "0","data_content": {"img_url":""},"return_msg": "No File"}
Which mean the request was processed successfully, and return proper message.
I was wondering why MultipartFormDataSection is not working with Error: 403.
Comment