ngreenwood6 Posted August 15, 2009 Share Posted August 15, 2009 I have 2 files: index.html <html> <title>Nick's Images</title> <head> <title>SilverlightApplication1</title> <script> function ajaxRequest(){ var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken) for (var i=0; i<activexmodes.length; i++){ try{ return new ActiveXObject(activexmodes[i]) } catch(e){ //suppress error } } } else if (window.XMLHttpRequest) // if Mozilla, Safari etc return new XMLHttpRequest() else return false } function postData() { var mypostrequest=new ajaxRequest() mypostrequest.onreadystatechange=function(){ if (mypostrequest.readyState==4){ if (mypostrequest.status==200 || window.location.href.indexOf("http")==-1){ document.getElementById("result").innerHTML=mypostrequest.responseText } else{ alert("An error has occured making the request") } } } var name=encodeURIComponent(document.getElementById("name").value) var description=encodeURIComponent(document.getElementById("description").value) var uploadedfile=encodeURIComponent(document.getElementById("uploadedfile").value) var parameters="name="+name+"&description="+description+"&uploadedfile="+uploadedfile mypostrequest.open("POST", "addImage.php", true) mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded") mypostrequest.send(parameters) } </script> </head> <body> <form enctype="multipart/form-data" method="post" action="addImage.php"> Name: <input type="text" id="name" name="name" size="25" /> <br /> Description: <input type="text" id="description" name="description" size="25" /> <br /> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> File: <input type="file" id="uploadedfile" name="uploadedfile" size="25" /> <br /> <input type="button" value="submit" onClick="postData()" /> </form> <div id="result"></div> </body> </html> test.php <?php $name = $_POST['name']; $description = $_POST['description']; echo 'Name: '. $name .' Description : '. $description .' File:'; echo $_FILES['uploadedfile']['name']; ?> I keep getting this error: Notice: Undefined index: uploadedfile in C:\wamp\www\test.php on line 6 I dont understand why its not working. Any help is appreciated. Quote Link to comment Share on other sites More sharing options...
trq Posted August 15, 2009 Share Posted August 15, 2009 Obviously a Javascript issue. Quote Link to comment Share on other sites More sharing options...
ngreenwood6 Posted August 15, 2009 Author Share Posted August 15, 2009 Any help is appreciated. I have been working on this for over 4 hours and cannot find any information on this. Quote Link to comment Share on other sites More sharing options...
trq Posted August 15, 2009 Share Posted August 15, 2009 Might help if you post your problem in the Ajax board. Quote Link to comment Share on other sites More sharing options...
ngreenwood6 Posted August 15, 2009 Author Share Posted August 15, 2009 I dont want to double post. Can a moderator move my post please. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.