Search Unity

Storing a screenshot and uploading it from a browser-based app to a web server

Discussion in 'Scripting' started by kenmarold, Jul 20, 2015.

  1. kenmarold

    kenmarold

    Joined:
    Jun 11, 2015
    Posts:
    27
    So I'm just looking for a quick primer on how I can upload a screenshot to a web server from a browser-based app. Since I can't save the file locally and then upload it, do I need to store it in a texture variable? I'm a little confused on the basics of this but I'm only looking to get pointed in the right direction. Everything I've researched online addresses using a string variable that points to the file location locally, but this won't work for a browser based app, correct? Just looking for some guidance on how to start building a POC for this. Thanks for the help.

    What I know: I can take the screenshot (but right now I only know how to save it to locally) I can upload a file (but only from a local path)

    Big question: How do I do I save the screenshot only in memory? Not sure if that's even the correct question but I hope someone knows what I'm trying to get at.

    Ultimately what I want to do is take a screenshot and then save it directly to a mysql server.
     
  2. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,089
    There's a few ways of taking a screengrab here: (file/texture etc..)

    http://ralphbarbagallo.com/2012/04/09/3-ways-to-capture-a-screenshot-in-unity3d/

    Once you have that you can upload using the WWW post function which takes a byte array as post data. (you can get your texture data as a raw byte[]). On your web server side you would need to take that byte array and save it out as a png or jpg.