I dragged two images onto an HTML5 page. I see the preview. Now I want to submit them to the server WITHOUT using the FormData object (for compatibility reasons).
HTML file
<html>
<head></head>
<body>
<img id="image1"/>
<img id="image2"/>
<form id="myform" action="otherpage.php" method="post">
</form>
</body>
</html>
After dragging two images onto the page, I see their previews in image1 and image2. In the debugger, I see that the src for image1 is data:image/jpeg;base64,/9j/4AAQSkZ...
and the src for image2 is data:image/jpeg;base64,/9j/4AAQSkZJRgA...
Using javascript, I want to submit those two images to otherpage.php. My idea is to create fields, and use their values as the source of the image.
function sendImages() {
var placeForm = document.getElementById('myform');
var textInput; //Create a local object
textInput = document.createElement('input'); //Create first <input> object
textInput.name='file1';
textInput.value=document.getElementById('image1').src; //Assign value to object
placeForm.appendChild(textInput); //Append object to form
textInput = document.createElement('input'); //Create second <input> object
textInput.name='file2';
textInput.value=document.getElementById('image2').src; //Assign value to object
placeForm.appendChild(textInput); //Append object to form
placeForm.submit(); //Send form
}
This results in an enormous memory hit that is cleared only when I shut down the browser or after displaying about:blank
.
Why is this?