0 votes

I was wondering if it's possible to create an in-game FileDialog so players could upload an image from their own PC to be used as a Sprite.
The first problem I noticed is that the FileDialog seems to be stuck under res:// directory, I can't access specific directories that weren't packed with the game.

Is there a way to allow players to upload their own image files to a game?
I mean, the server (Itch.io for example) would not store that image, the game would just read it and create a Texture that then would be attached to a Sprite. I don't know what type of HTTP request shenanigans this would involve.

in Engine by (28 points)

1 Answer

0 votes

Regarding the problem with the FileDialog being stuck under res:// did you set the "access" property?

By default, this is set to limit access to only res:// . So, in your case you need this to be either User data (ACCESSUSERDATA = 1) or Filesystem (ACCESSFILESYSTEM = 2), right?

Using this I was able to popup a FileDialog and browse my local filesystem

There is an example of usage here

by (490 points)

That solves the FileDialog part for desktop builds, but for HTML5 the file dialog then stays under a / directory containg the following paths:
- dev - home - proc - tmp - userfs - <project_name>.pck
I didn't find those paths on my system and I'm testing the HTML5 build on itch.io so I suppose that may be itch.io file system?

Yes, that is part of a standard unix filesystem (minus bin, sbin, etc, usr and lib).

This is how itch.io describe how html5 works on their platform : "itch.io supports HTML5 games by embedding an iframe pointing to your game on itch.io’s own game page.", so that must be the filesystem of where your game is hosted in itch.io.

I guess they won't let you write to that, but you might be able to save things in the home folder (or a subfolder)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.