kfir91 Posted November 26, 2010 Share Posted November 26, 2010 its my ajax code : function uploadFile(dir) { http.open("POST", "mod/filesManager/uploadFile.php",true); http.onreadystatechange = function() { if(http.readyState == 4){ alert(http.responseText); showManager(dir); } } http.send(null); } its uploadFile.php file : <?php error_reporting(0); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Cache-Control: no-cache"); header("Pragma: no-cache"); header("Content-type: text/html; charset=windows-1255"); include("../db.php"); include("../functions.php"); $uploaddir = security($_GET['dir']); $uploadfile = "".$uploaddir." / ".basename($_FILES['filename']['name']).""; echo "<p>"; if (move_uploaded_file($_FILES['filename']['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded.\n"; } else { echo "Upload failed"; } echo "</p>"; echo '<pre>'; echo 'Here is some more debugging info:'; print_r($_FILES); print "</pre>"; ?> now in php file the $_FILES empty why i need to do ? Link to comment https://forums.phpfreaks.com/topic/219918-i-have-problem-with-phpajax-upload-files/ Share on other sites More sharing options...
sweeb Posted December 2, 2010 Share Posted December 2, 2010 You should check out this link: http://stackoverflow.com/questions/543926/is-it-possible-to-ajax-a-file-upload/543927#543927 Basically you can't set the enctype with AJAX so you have to do a workaround either with an iframe or flash Link to comment https://forums.phpfreaks.com/topic/219918-i-have-problem-with-phpajax-upload-files/#findComment-1142207 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.