I am trying to make a simple upload file system, and this is my code , I hope you can help me, help very appreciated
init.php
<form method="post" action="" enctype="multipart/form-data">
<label for="file">Upload a file</label>
<input type="file" name="file" id="fileArchivo" />
<input type="submit" name="submit" id="btnUpload" value="Upload file" />
</form>
Ajax mootools method
window.addEvent("domready",function(){
cargarIndex();
});
function loadIndex()
{
var Request = new Request({
method: 'POST',
url: '../CONTROLLER/init.php',
onRequest: function() {},
onSuccess: function(text, xmlrespuesta){
document.getElementById('archive').innerHTML= texto;
$('btnUpload').addEvent('click',function(){uploadFile()});
},
onFailure: function(){alert('Error!');}
}).send();
}
function uploadFile(){
//$('btnUpload').addEvent('click', function(){
alert('in');
archivo = $('fileArchivo').value;
alert(archivo);
var nuevoRequest = new Request({
method: 'POST',
data: 'archivo='+archivo,
url: '../CONTROLLER/controllerSave.php',
onRequest: function() {$('subirarchivo2').innerHTML="Cargando...";},
onSuccess: function(texto, xmlrespuesta) {$('subirarchivo2').set('html',texto);},
onFailure: function(){alert('Error!');}
}).send();
//});
}
Firebug says that uncaught exception:
[Exception... "prompt aborted by user" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: resource://gre/components/nsPrompter.js :: openTabPrompt :: line 468" data: no]
But I dont get the answers, I already search but nothing, the Error alert is in the onFailure in the uploadFile.
can't use ajax like so to upload files.
http://mootools.net/forge/p/form_upload by core member Arian
http://mootools.net/forge/p/uploadmanager by Thiery Bela
Both provide sensible solutions via HTML5 interfaces with a flash uploader fallback / degradation for older browsers.
User contributions licensed under CC BY-SA 3.0