Thursday, 26 September 2013

How send file on javascript?

How send file on javascript?

Code:
var photo = 'http://cs323230.vk.me/u172317140/d_5828c26f.jpg';
var upload_url = 'http://cs9458.vk.com/upload.php?act=do_add&mid=62..';
var xmlhttp = getXmlHttp();
var params = 'photo=' + encodeURIComponent(photo);
xmlhttp.open("POST", upload_url, true);
xmlhttp.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
if(xmlhttp.status == 200) {
var answer2 = xmlhttp.responseText;
console.log(answer2);
alert(answer2);
}
}
};
xmlhttp.send(params);
Me need change url photo on the contents of the file which find on path
'./DirectoryImage/imagetest.jpg' and send contents of the file
'./DirectoryImage/imagetest.jpg' on upload_url.
But i not know how send the contents of the file on upload_url in
javascript...
It really?
Anyone know how make it?

No comments:

Post a Comment