Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by barker_s · Dec 21, 2012 at 07:16 PM · wwwscreenshotupload

File uploading works in editor, but not in build

Hello,

I'm trying to implement a function in my project that would save a screenshot and then send it to a pre-defined location with the WWW class. Sounds relatively simple, but it's giving me a hard time. The problem is - when I start my app in the editor, it works fine, uploads the file and everything. When I build it, however, it takes the screenshot, but doesn't upload it anymore. The WWW class throws an error "Open file error: Couldn't open file", which is vague at best. Anybody got an idea what I'm doing wrong here? Here's the code I'm using for my Screenshot Manager:

     public IEnumerator TakeScreenShot(string name)
     {
         Debug.Log("Starting TakeScreenShot");
         string fileName = name + " " + System.DateTime.Now.ToString().Replace(":", ".").Replace("/", "-") + ".png";
         
         Debug.Log("Filename set - " + fileName);
         
         Debug.Log("Coroutine 1 starting...");
         yield return StartCoroutine("HideCam");
         Debug.Log("Coroutine 1 ended.");
         
         Debug.Log("Coroutine 2 starting...");
         yield return StartCoroutine("CapScreen", fileName);
         Debug.Log("Coroutine 2 ended.");
         
         Debug.Log("Coroutine 3 starting...");
         yield return StartCoroutine("ShowCam");
         Debug.Log("Coroutine 3 ended.");
 
         
         System.IO.FileInfo fi = new System.IO.FileInfo(fileName);
         
         GameObject fm = GameObject.Find("FileUpload");
         
         FileUpload uploadManager = (FileUpload)fm.GetComponent("FileUpload");
         
         string existingFile;
         
         existingFile = fi.FullName.Replace("\\","/");
         
         Debug.Log("File name generated - " + existingFile);
         Debug.Log("Waiting for 0.5 seconds...");
         yield return new WaitForSeconds(0.5f);
         Debug.Log("Wait edned. Starting upload...");
         uploadManager.UploadFile(existingFile, uploadLocation);
         
         
         yield return new WaitForSeconds(0.5f);
         
         if(uploadManager.GetSuccess() == true)
                 fi.Delete();
         
         yield return 1;
         
         uploadManager.ResetSuccess();
 
     }

For uploading I use WWW + php script combination.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by barker_s · Jan 11, 2013 at 11:16 AM

Ok, I've figured it out a while ago and thought that I'd share it with you.

It seems that the culprit was FileInfo class - it kept the file from sending. As far as I was concerned it shouldn't keep a handle to the file, but removing it from the code solved my problem (had to pass the path of the file different way).

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to Convert MovieTexture to Byte? 1 Answer

How to upload a file from Android to my own website? 0 Answers

uploading png with wwwform 0 Answers

Returning correct result after uploading 0 Answers

Opening iOS and Android Photos to upload? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges