UPLOAD IMAGE DISPLAY CODE

HI,
I'm triyng to insert upload string.
Player choose image by his computer

show your image

but the image won't display.

CAN U HELP ME?
Thanx


I assume you're uploading the image to some external site?

This is likely to be hard to get working. If you have some code already, you could show us and see if anyone can sot what's wrong with it.


Yes,the player choose the image by his pc.
On Quest doesn't work.

This is the code:


This is the code:

<input type="file" accept="image/*" onchange="loadFile(event)">
<img id="output"/>
<script>	
  var loadFile = function(event) {
    var output = document.getElementById('output');
    output.src = URL.createObjectURL(event.target.files[0]);
        };
 </script>

K.V.

Do it like this:

<input type="file" accept="image/*" onchange="loadFile(event)"/>
<img id="output"/>
<script> var loadFile = function(event) {    var output = document.getElementById('output');    output.src = URL.createObjectURL(event.target.files[0]);        }; </script>

image


Thanks a lot.
U'RE THE BEST.
Wonderful


K.V.

No problem!

Quest adds a <br/> in the code for every line break.

So it was turning your script into this behind the scenes:

<script> <br/> var loadFile = function(event) {<br/> var output = document.getElementById('output');<br/> output.src = URL.createObjectURL(event.target.files[0]);<br/> }; <br/></script>


K.V.

PS

I totally stole your code and put it on my Wiki. (I did mention you, though.)

https://github.com/KVonGit/QuestStuff/wiki/Import-an-Image-Using-HTML-and-JS


K.V.

PPS

If you add this to the end of the script, you can save the data as a variable to print the image whenever you like (as long as the game isn't exited and loaded from a saved game):

uploadedImg = output.src;

To use that:

JS.eval("addTextAndScroll (\"<img src='\"+uploadedImg+\"'>\");")

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums