alex.C
12-08-2011, 03:10 PM
Hi there,
I am trying to build an interface to upload files and change some of the form (hidden) values depending on the file uploaded, here is where I got so far:
$('#buttonUpload').click(function (){
$.ajaxFileUpload({
url:'doajaxfileupload.php',
secureuri:false,
fileElementId:'fileToUpload',
dataType: 'txt',
success: function (data, status){
alert("File is uploaded,");
if(typeof(data.error) != 'undefined'){
if(data.error !=''){ alert(data.error); }
else{ alert(data.msg); }
}
document.getElementById('buttonUpload').style.color="green";
document.getElementById('isfileuploaded').value="green";
},
error: function (data, status, e){ alert(e); }
});
return false;
});
My problem is that I want doajaxfileupload.php to return a variable to javascript/change some html form value. The code works as it is for the file upload, I just need to add something for the output, any suggestion?
Edit: I just noticed that some previous part of the code is still there: the part that changes the color of the button depending if the file is uploaded or not. Now I want those values to change depending on what file is uploaded.
I am trying to build an interface to upload files and change some of the form (hidden) values depending on the file uploaded, here is where I got so far:
$('#buttonUpload').click(function (){
$.ajaxFileUpload({
url:'doajaxfileupload.php',
secureuri:false,
fileElementId:'fileToUpload',
dataType: 'txt',
success: function (data, status){
alert("File is uploaded,");
if(typeof(data.error) != 'undefined'){
if(data.error !=''){ alert(data.error); }
else{ alert(data.msg); }
}
document.getElementById('buttonUpload').style.color="green";
document.getElementById('isfileuploaded').value="green";
},
error: function (data, status, e){ alert(e); }
});
return false;
});
My problem is that I want doajaxfileupload.php to return a variable to javascript/change some html form value. The code works as it is for the file upload, I just need to add something for the output, any suggestion?
Edit: I just noticed that some previous part of the code is still there: the part that changes the color of the button depending if the file is uploaded or not. Now I want those values to change depending on what file is uploaded.