<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>

<script>

function postimage()
{
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange= function()
{
document.getElementById("image").innerHTML=xmlhttp.responseText; 
}
posted={
fname:document.getElementById("name").value,
picture:document.getElementById("image1").value.replace('C:\\fakepath\\', 
"http://127.0.0.1:8000/media/photos/";)

}

xmlhttp.open("POST","http://127.0.0.1:8000/api/v3/filedata/",true);
xmlhttp.setRequestHeader("Content-type","application/json");
xmlhttp.setRequestHeader("X-CSRFToken", '{{ csrf_token }}');
console.log(posted);
xmlhttp.send(JSON.stringify(posted));
}

</script>

</head>
<body onload="get()">
<p id="sampledata1"> status data </p>
<p id="image"> sample image </p>
<input type="file" id="image1">
<br>
<br>
name:<input id="name" placeholder=" enter your name">
<br>
<br>
person:<select id="person" placeholder="enter your pg ">
</select>

<br>
<br>
<button onclick="change()"> Post </button>
<button onclick="postimage()"> post image </button>
</body>
</html>


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f0038e27-743b-449a-9bc7-54e64ab1485co%40googlegroups.com.

Reply via email to