i want to uploaded image to server from from anroid and ios device to server.I am using following code it is working fine in editor to upload the file from my windows system but code fails when uploaing from anroid and ios device after i tested in app file.
IEnumerator UploadFileCo(string localFileName, string uploadURL)
{
WWW localFile = new WWW("file:///" + localFileName);
yield return localFile;
if (localFile.error == null)
Debug.Log("Loaded file successfully");
else
{
Debug.Log("Open file error: " + localFile.error);
yield break; // stop the coroutine here
}
WWWForm postForm = new WWWForm();
// version 1
//postForm.AddBinaryData("theFile",localFile.bytes);
// version 2
postForm.AddBinaryData("theFile", localFile.bytes, localFileName, "text/plain");
WWW upload = new WWW(uploadURL, postForm);
yield return upload;
if (upload.error == null)
Debug.Log("upload done :" + upload.text);
else
Debug.Log("Error during upload: " + upload.error);
}
please help me how to upload the file from anroid and ios device
↧