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 the1plummie · May 03, 2013 at 10:13 PM · wwwformwww class

Sending binary data not working with apache + php now

here's example form:

 WWWForm form = new WWWForm();
 form.AddField("foo","bar");
 form.AddField("baz","bad");
 
 //image_data is the screenshot in png format
 form.AddBinaryData("image", image_data ) ;

and i'm getting this jumbled array in $_POST data:

 Array
 (
  [
 --j9WOVWjhzifMBMOxK4Gcn4HcAYobnKmq3WyCjNiJ
 Content-Type:_text/plain;_charset] => "utf-8"
 Content-disposition: form-data; name="foo"
 
 bar
 --j9WOVWjhzifMBMOxK4Gcn4HcAYobnKmq3WyCjNiJ
 Content-Type: text/plain; charset="utf-8"
 Content-disposition: form-data; name="baz"
 
 bad
 009480823dc102f6f612ffb2c0e5fb79647c60a950c0c84c430f43c72869c0aa
 --j9WOVWjhzifMBMOxK4Gcn4HcAYobnKmq3WyCjNiJ
 Content-Type: image/png
 Content-disposition: form-data; name="map_image"; filename="map_image.png"
 
 \x89PNG
 \x1a\n

any ideas?

Comment
Add comment · Show 4
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
avatar image mgeorgoulopoulos · Jun 01, 2013 at 11:44 AM 0
Share

I am getting the same output, did you have any luck fixing this?

avatar image Graham-Dunnett ♦♦ · Jun 01, 2013 at 11:49 AM 0
Share

What's jumbled about that? Looks like 3 sections, each with the expected data to me. The only gotcha I see is the PNG section seems to be cut short, possibly because it contains a NULL character which makes the PHP array dumping code think it's got to the end of the data. Well, I guess the line after bad is actually part of the PNG file, so maybe that's odd.

avatar image mgeorgoulopoulos · Jun 01, 2013 at 11:59 AM 0
Share

In my case, this is the php code that I have for uploading the file. It seems that it doesn't get past the if ( isset($_POST['action')) line:

 if ($_POST)
 {
     if (isset ($_POST['action'])) 
     {
         if ($_POST['action'] == 'upload')
         {            
             // backwards compatibility with old servers
             if (!isset($_FILES) && isset($HTTP_POST_FILES))
             {
                 $_FILES = $HTTP_POST_FILES;
             }
             
             if ($_FILES['file']['error'] == UPLOAD_ERR_O$$anonymous$$)
             {
                 if ($_FILES['file']['name'] != "")
                 {
                     if ($_FILES['file']['type'] == 'text/json')
                     {
                         $uploadfile = dirname(__FILE__) . '/' . $_FILES['file']['name'];
                         
                         move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile);
                     }
                 }
             }
         }
     }
 }


The same php (and the same c# code) work fine on a non-apache server that I have tried.

avatar image Graham-Dunnett ♦♦ · Jun 01, 2013 at 12:00 PM 0
Share

Sounds like you need an Apache server q&a site.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by the1plummie · Jun 02, 2013 at 01:24 PM

actually upgrading to unity 4.1.3 seem to make the issue go away. and make sure you have the right header for content type. :) (actually not specifying header works as well)

Comment
Add comment · Show 2 · 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
avatar image mgeorgoulopoulos · Jun 02, 2013 at 05:48 PM 0
Share

Ahh I cannot upgrade to Unity 4.0 :( I want the game to be published with 3.5 as this is what I have purchased, can't really afford to buy a new license.

Are there no other workarounds? I am sure I have the right header. I also tried not specifying a header, I got the same result basically.

avatar image the1plummie · Jun 02, 2013 at 08:54 PM 0
Share

sorry i've always being on unity 4.0+ so not sure about older versions. what content type header are you using btw?

avatar image
0

Answer by mgeorgoulopoulos · Jun 02, 2013 at 09:52 PM

Content type is text/json. I have tried everything else, even not specifying a header hashtable at all, I still cannot get this to work.

The thing is it works on the non-apache server, so it has to be something server related. I tried speaking to the hosting support with no luck :(

Comment
Add comment · Show 2 · 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
avatar image the1plummie · Jun 02, 2013 at 10:00 PM 0
Share

hmm, if the data you needed to send is json encoded string, you don't need to send it using binary format. why can't you just put that in WWWForm post data? if it's small enough, you might be able to fit it in url itself.

avatar image mgeorgoulopoulos · Jun 05, 2013 at 06:13 PM 0
Share

How would I do that? Don't I still need to upload it somehow? It cannot fit in the url as it's a quite long file (or at least, it will become long soon).

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

14 People are following this question.

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

Related Questions

Use the data received from WWW in UI 1 Answer

WWW Class is acting up 1 Answer

Cloud recognition in Vuforia 0 Answers

Is there a way to fix uploadprogress on mobile? 1 Answer

Post image to facebook wall 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