How to send javascript variable data to php
This question already has an answer here:
等待$.post()
成功。
function wl(){
window.location = "http://localhost/file/handler.php";
}
var base64 = this.tobase64(); // store base64 value to this variable
$.post('/js/uploadify/effectsuploadify.php',{
basevalue: base64,
success: wl,
});
POST only sends the value of form's feilds to next page. In order to send your image to next page, assign it to value of hidden feild and submit form using java script.
var form = document.createElement("form");
form.setAttribute("method", "POST");
form.setAttribute("action", "http://localhost/file/handler.php");
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", "image");
hiddenField.setAttribute("value", base64);
form.appendChild(hiddenField);
document.body.appendChild(form);
form.submit();
链接地址: http://www.djcxy.com/p/21922.html