Before I get to my problem, I apologize for the errors I'm going to make with the terminologies. New to jQuery and learning!
So I have a form with two fileds, text and a file type.
<form method="post" action="" enctype="multipart/form-data">
text <input type='text' id="textf" /><br>
images <input type='file' id="imagef" /><br>
<button name="submit" type="submit" id="submit">Finish</button>
</form>
The image that is uploaded has to be compressed and then uploaded. (I got that part done!). The compressed image is then saved on the page below the form as a dataurl(?).
This format,
<img id="result_image" class="img_container" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD.... ">
Now, when the form is submitted the generated compressed image has to be uploaded instead on the original image.
I am using jquery to do so, but my lack of knowledge is getting in the way of doing so. Here's where I need your help, stackoverflow.
I've gotten this far,
$(document).ready(function(){
$("#submit").click(function(e){
e.preventDefault();
var formData = {
'textf' : $('#textf').val(),
'imagef' : $('#result_image')[0]
};
$.ajax({
type : 'POST',
url : 'upload.php',
data : formData,
dataType : 'json',
encode : true
})
});
});
The response from the php script upload.php is,
fweArray
(
[textf] => fwe
)
The image isn't there! What I'm I doing wrong her? I appreciate any help.