Oke I am back :S This are 2 ways I tried, but did not work
<DIV class='fillDBwrapper' id='divFotos'><INPUT type='file' name='uploaded' id='uploaded' onChange="load('addFoto.php', 'divFotos');"/><INPUT type='file' name='uploaded' id='uploaded' onChange="addFoto('divFotos')"/></DIV>
addFoto.php:
if ($_FILES['uploaded']['name']){echo "FILE SELECTED";}else{echo "NO FILE SELECTED";}die;
The first one ("load") is an AJAX function? How can I asign that function to my page?The second one runs, and also echo's to the right div, but echo's NO FILE SELECTED! Has to be with the problem, that JS is userside and PHP is serverside, but cant get it managed... Javascript:
function addFoto(targetDiv){fillContent('modules/secure/addFoto.php', targetDiv);} var xmlhttp;function run_xmlhttp() {if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safarixmlhttp=new XMLHttpRequest();}else {// code for IE6, IE5xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}}function fillContent(content, targetDiv){run_xmlhttp();xmlhttp.onreadystatechange=function() {if (xmlhttp.readyState==4 && xmlhttp.status==200) {document.getElementById(targetDiv).innerHTML=xmlhttp.responseText;}}xmlhttp.open('GET', content, true);xmlhttp.send();}
I rather dont want to use a FORM for above, cause this is already in a FORM... and form inside form wont work...Is it possible to send the 'addPhoto.php' to the same div as where the input file button is? This div show the already added pictures, but when clicking the input file button, then I want user to pick a photo from pc and after picked picture, php saves picture to server, and the div has to be reloaded, showing also the just newly added picture... I don't want a submit button, but I want code running right after user picked a picture from pc... (and yes code is checking for extension, to make sure picture has picked.... if not, user gets an error, so has to pick again... I hope I am clear about this, with my not 100% perfect English...