[Solved] FormData to XMLHTTPRequest 03-24-2017, 09:31 PM
#1
I have this... Kinda working?
What's happening right now is that the process freezes since I didn't define the boundary for the multipart/form-data however when I do, it still doesn't work. The process goes through however it cannot find what I need it to.
Here is the output with the boundary defined:
Here is the form data code:
I run a second receive server on port 3000 however that irreverent since the error is on the client side.
I'm not really sure what to do at this point, Heck I've even tried going to Mozillas dev wiki.
I know how to do this on jQuery however since I'm don't really want to use jQuery, I am asking this. However as a last result I will use it.
Thanks!
EDIT:
I found out that you can no longer save a file right through AJAX, you have to save it to a FormData.... Fuck that.
I turned it into a DataURI then DataURI.toString() from which I sent it to the server, the server then saves that data as a local file and sends it to whoever I want via mailgun.
What's happening right now is that the process freezes since I didn't define the boundary for the multipart/form-data however when I do, it still doesn't work. The process goes through however it cannot find what I need it to.
Here is the output with the boundary defined:
Code:
{ from: 'undefined undefined <undefined>',
to: 'ERADICATED',
subject: 'New Application from Contact Form',
text: undefined,
html: undefined }
Here is the form data code:
Code:
function sendEmail() {
msgEmltxt = 'Name: ' + fName.value + " " + lName.value + "\n";
msgEmltxt += 'Email: ' + emailAddr.value + "\n";
msgEmltxt += 'Phone: ' + phone.value + "\n";
msgEmltxt += 'Position Applying To: ' + posApply.value + "\n";
if (msgEml.value.toString() != "") {
msgEmltxt += 'Message: ' + msgEml.value;
}
msgEmlHtml = "<p><b>Name</b></p><p> " + fName.value + " " + lName.value + "</p>";
msgEmlHtml += "<p><b>Email</b></p><p> " + emailAddr.value + "</p>";
msgEmlHtml += "<p><b>Phone</b></p><p> " + phone.value + "</p>";
msgEmlHtml += "<p><b>Position Applying To</b></p><p> " + posApply.value + "</p>";
if (msgEml.value.toString() != "") {
msgEmlHtml += "<p><b>Message</b></p><p> " + msgEml.value + "</p>";
}
formData.append('resume', resumeFile.files[0], resumeFile.name);
formData.append('firstName', fName.value);
formData.append('lastName', lName.value);
formData.append('emlAddr', emailAddr.value);
formData.append('messageTxt', msgEmltxt);
formData.append('messageHtml', msgEmlHtml);
subBtn.disabled = true;
/*httpRequest.open('POST', 'https://ERADICATED:3000/sendResume', true);
httpRequest.setRequestHeader("Content-Type", "multipart/form-data; boundary=" + formData.boundary);
httpRequest.send(formData);*/
}
I run a second receive server on port 3000 however that irreverent since the error is on the client side.
I'm not really sure what to do at this point, Heck I've even tried going to Mozillas dev wiki.
I know how to do this on jQuery however since I'm don't really want to use jQuery, I am asking this. However as a last result I will use it.
Thanks!
EDIT:
I found out that you can no longer save a file right through AJAX, you have to save it to a FormData.... Fuck that.
I turned it into a DataURI then DataURI.toString() from which I sent it to the server, the server then saves that data as a local file and sends it to whoever I want via mailgun.
(This post was last modified: 03-28-2017, 06:54 PM by ProfessorChill.
Edit Reason: Solved
)