- Home /
File upload from within unity
Hi,
Is it possible to create a file upload input box within unity? I know it is possible to upload files using unity using the www class functions but I can't find anything for selecting a file from a local machine to then upload.
Thanks,
eb_dev
Answer by Maarten · Nov 24, 2010 at 10:16 AM
You can question all files and folders trough the following code:
DirectoryInfo info = new DirectoryInfo(@"C:\");
foreach (FileInfo file in info.GetFiles())
{
Debug.Log(file.FullName);
}
Then get a filestream of your wanted file using
FileStream fileStream = new FileStream("Path here", FileMode.Open);
And use that stream in your upload. Dont forget to import System.IO.
(This code is C#, as far as i know you cannot do this with Javascript)
thanks for your speedy reply $$anonymous$$aarten. With this I would have to create some sort of file selection window myself wouldn't I?
Yes you should. There is no component in Unity to do this. But it wouldnt be really hard to create one with the GUI components that are available.
ok great, I'll look into doing that then. Thanks again.
Forgive me, but how is the Filestream used with the WWW object for uploading, exactly?
Answer by Laplage726 · Feb 25, 2013 at 09:32 PM
Can anyone tell me how to upload a scene file through Winscp? How should I save the file? I am having maximum trouble here.
Your answer
Follow this Question
Related Questions
WHY WONT IT WORK? 1 Answer
Failed to upload image over custom server 3 Answers
Upload zip file from one client to another over network 0 Answers
Uploading Unity to Website 1 Answer