How can i send image from the client side to server?
i have a simple form like :
<form>
<input type="file" id="myfile" name="myfile" />
<input type="button" value="Submit" onclick="SendImageToServer();" />
<iframe id="uploadframe" name="uploadframe" src="upload.php" width="8" height="8" scrolling="no" frameborder="0"></iframe>
</form>
And in the method i am using is :
function sendImage(){
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
//I want to get the response as simple <img scr="myimage"/>
}
Can anyone help me how can i do this using Ajax-php.(NO JQUERY)?
Well, for one thing you cannot send files with AJAX. But if you are submitting to an iframe, then the form needs to have enctype=”multipart/form-data” defined, otherwise it does not submit files.