0
I’m doing a test with the script below, for file upload:
function uploadFile(){
var file = _("file1").files[0];
// alert(file.name+" | "+file.size+" | "+file.type);
var formdata = new FormData();
formdata.append("file1", file);
var ajax = new XMLHttpRequest();
ajax.upload.addEventListener("progress", progressHandler, false);
ajax.addEventListener("load", completeHandler, false);
ajax.addEventListener("error", errorHandler, false);
ajax.addEventListener("abort", abortHandler, false);
ajax.open("POST", "file_upload_parser.php");
ajax.send(formdata);
}
What happens is that besides the file itself, I need to send 3 more text fields. I tried with a field as follows:
var teste = $('input:text[name=teste]').val();
formdata.append("teste", teste);
But the following error occurs:
How can I send these variables? And arquivo file_upload_parser.php
how can I receive these variables?
Diego it seems that the mistake is
$
that is not set? you use some plugin or extension that needs thejQuery
guy:_("file").files[0]
?– novic
I’m not using plugins...
– Diego
_("file1").files[0];
and that code comes from where?– novic
var teste = $('input:text[name=teste]').val();
look where the problem is this is jQuery and you said you’re not usingplugin
orframework js
may be the problem. Then usedocument.getElementById
and take the value!– novic
It is the _files form that is working. I will test with getElement
– Diego
It worked with getElement. But how do I get it on the other page?
– Diego
Let’s go continue this discussion in chat.
– novic