I am sending by parameter upload_preset
, and this corresponds to the name of the text field, but from javascript I would like to send another parameter called folder
with the value, myvalue
. how can I do it without needing to add another text field called folder
?
<form action="" method="post" enctype="multipart/form-data" onsubmit="AJAXSubmit(this); return false;">
<fieldset>
<legend>Upload example</legend>
<p>
<label for="upload_preset">Unsigned upload Preset: <input type="text" name="upload_preset" value="xx">(set it <a href="https://cloudinary.com/console/settings/upload#upload_presets">here</a>)</label>
</p>
<p>
<label >Select your photo:
<input type="file" name="file"></label>
</p>
<p>
<input type="submit" value="Submit" />
</p>
<img id="uploaded">
<div id="results"></div>
</fieldset>
</form>
window.AJAXSubmit = function (formElement) {
if (!formElement.action) { return; }
var xhr = new XMLHttpRequest();
xhr.onload = ajaxSuccess;
xhr.open("post", "https://api.cloudinary.com/v1_1/xxx/image/upload");
xhr.send(new FormData(formElement));
}