Upload files to a database

I’m making an app that requires to upload a file, for example, a pdf file to a database, I’v read you can upload data from de game to a database, is it possible to do this with an external file?

Unity is able to handle files uploads.

In the Scripting API for WWWForm there is an example about how to send a png file by POST to a given URL. By doing this, you also must to program, for example, a php script to receive the file and upload it to the database.

You also should check the Scripting API for WWW class because both classes work together.


Anyway, I tell you that to do this in a professional manner you also need to know how to coding a secure web script using hashes and some Apache config files to block accesses from browsers, for example. It should be enough programming a MD5 test like it’s done in this tutorial

Lastly, let me give you the link of two of my GitHub repos that work together, as one is a Unity Game and the other a web that stores his highscores:

  • No-Mans-Flappy-Unity. Check how the WWW scripts work, in the folder Assets/Scripts/WWW.
  • No-Mans-Flappy-web. Check the php/game-scripts folder, as there are all the URL’s that will be accessed by the WWW scripts.

That’s all. Now you have all the needed tools to learn how to upload a file to a database. Happy coding!

i suggest you to write an app using any jdk or ios developement kit, cus unity is kind of a game engine, and its main purpose is for games, so, it won’t provide much convenient and features for writing an app.