- Home /
upload image to server
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
Comment
Your answer
Follow this Question
Related Questions
Dim Screen but Don't Lock 0 Answers
Changing view based on device 0 Answers
GUI Size on different Android/iOS Devices? 3 Answers
Mobile aspect ratio and scaling - Use 16:10 or 16:9 base for full screen background ? 0 Answers
Is it possible to check if the touchscreen keyboard has been closed? 0 Answers