Reputation: 503
I'm using the html5 canvas to drag and drop file uploads but I need to send additional info with the dropped files. specifically a recordID. I'm sending my file to php like this :
canvasData = canvas.toDataURL('image/jpeg');
var ajax = new XMLHttpRequest();
ajax.open("POST", './php/uploadImage.php', false);
ajax.setRequestHeader('Content-Type', 'application/upload');
ajax.send(canvasData);
How do I add an additional param of recordID = recordID along with the file?
Upvotes: 1
Views: 1349
Reputation: 2053
I fixed it with
ajax.open("POST", './php/uploadImage.php?recordID=' + recordID, false);
ajax.setRequestHeader('Content-Type', 'application/upload');
ajax.send('recordID='+recordID+'&'+canvasData);
Upvotes: 0
Reputation: 359846
You can send it as a URL query parameter:
ajax.open('POST', './php/uploadImage.php?recordID' + recordID, false);
Upvotes: 1