Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to save form submitted image file #1

Open
hyakugei opened this issue Jan 25, 2017 · 5 comments
Open

Unable to save form submitted image file #1

hyakugei opened this issue Jan 25, 2017 · 5 comments

Comments

@hyakugei
Copy link

Using both the following code examples, i am unable to convert the MultipartFormEntry.Value into a valid image file. Note that these lines have been added to the example FileUpload class.

Example 1

public void HandleRequest (Request request, Response response)
{
    var mpf = MultiPartEntry.Parse(request);
    var filePath = Path.Combine(Application.dataPath, "Image.png");
    var bytes = System.Text.Encoding.UTF8.GetBytes(mpf["fileToUpload"].Value);
    File.WriteAllBytes(filePath, bytes);

    response.statusCode = 200;
    response.message = "OK.";
    response.Write(html.text);
}

Example 2

public void HandleRequest (Request request, Response response)
{
    var mpf = MultiPartEntry.Parse(request);
    var filePath = Path.Combine(Application.dataPath, "Image.png");
    File.WriteAllText(filePath, mpf["fileToUpload"].Value);

    response.statusCode = 200;
    response.message = "OK.";
    response.Write(html.text);
}

This the original file on the left, and the saved file on the right. Will continue to test.

sel_140

@Personuo
Copy link

Personuo commented Oct 5, 2020

Hello, have you solved this problem?

@hyakugei
Copy link
Author

hyakugei commented Oct 5, 2020

I never found a fix.

@Personuo
Copy link

Personuo commented Oct 5, 2020

Have you later found any way for unity to act as an http server and send files to unity via the web client?
I want players to be able to upload their pictures and mp3 files to unity via the web.

@hyakugei
Copy link
Author

hyakugei commented Oct 5, 2020

Nothing public, it was 3 years ago i was working on this, and i can't even remember how i solved it, or even if i solved it. Sorry.

@Personuo
Copy link

Personuo commented Oct 5, 2020

Nothing public, it was 3 years ago i was working on this, and i can't even remember how i solved it, or even if i solved it. Sorry.

Ok,thank you for this reply.Good day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants