x


File IO on a server file from the web-player

I understand that it is not possible to open/write files on the user's local system from within the Unity3D webplayer. However, is it possible to open/write a file on the server which the webplayer is hosted on?

more ▼

asked Feb 23 '10 at 12:49 PM

Extrakun gravatar image

Extrakun
1.3k 44 56 70

(comments are locked)
10|3000 characters needed characters left

2 answers: sort oldest

Unity works just like Java/Flash or any other browser plugin in this regard. It is run on the client machine - not the server and can therefore only physically have access to the client file system. Most plugins (including the Unity plugin) restricts this access though - to prevent malicious content from accessing private user data or wreaking havoc on the drives of unsuspecting web surfers.

So you have direct access to neither. PlayerPrefs is the exception - working a bit like website cookies for storing a limited amount of information on the client machine. If you need access to data on the server hosting the web player, you will need to gain this access the same way any other client hosted process does: via a web request.

WWW is excellent for this - running http POST and GET calls through the browser running the plugin - this means you get benefits such as following the proxy and other connection settings set in the browser and browser caching.

A common setup is using the WWW class to send a request to a PHP script on the hosting server which then returns the requested data. Ofcourse if you just need a single file - like a picture, you could just request that directly.

more ▼

answered Feb 24 '10 at 09:38 AM

AngryAnt gravatar image

AngryAnt ♦♦
4k 14 19 52

(comments are locked)
10|3000 characters needed characters left

you can use a server side http://ASP.NET or PHP script to read/write what you want on the server. i did not test if http://System.IO works on server files or not but i know adding the library to your web player will increase it's size.

more ▼

answered Feb 23 '10 at 01:10 PM

Ashkan_gc gravatar image

Ashkan_gc
9.1k 33 56 117

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x815
x56

asked: Feb 23 '10 at 12:49 PM

Seen: 2710 times

Last Updated: Feb 24 '10 at 11:01 AM