I’m currently developing one component for joomla and on the front end i need tu upload photo…. The php code for upload is ready… The problem is that i want to make the pic upload onchange of file field named logo but it says that there’s no such entry(javascript does not pass the fieldvalue or something)
Notice: Undefined index: logo in /var/www/furnish/components/com_furnishing/controller.php on line 21
My javascript code is
jQuery(function(){
console.info("ok");
jQuery('input[name="logo"]').change(function(){
var val=jQuery(this).val();
var filename = jQuery('input[name="logo"]').val();
//var forma = $(this);
//
// jQuery('input[name="task"]').val('register.upload');
console.log(filename);
$(this).ajaxSubmit({
type: "POST",
url: "index.php?option=com_furnishing&task=upload",
enctype: 'multipart/form-data',
data: jQuery('form[name="Form"]'),
success: function (dati) {
alert("Data Uploaded: "+dati);
}
});/*
jQuery('input[name="task"]').val('register.upload');
jQuery.post('index.php?option=com_furnishing&task=upload',$("form[name='Form']"),function(data){
if (data)
{
jQuery('input[name="logo"]').val(data);
}
else
{
jQuery('input[name="logo"]').val('');
}
alert(data);
console.info(data);
});
jQuery('input[name="task"]').val('register.regme');*/
console.info("ok");
});
});`
The part which is commented out has the same problem. So the question is how to make it work?
Thank you!
After a long time i managed to figure this out. As one of the forums told that there is no way to post file field i managed to create a
jQuerycheck which checks for the file size,type….. Beacose i needed to check for file type and size that was the fasstest and easyest way to do it.