hi,the codes below were just a short version of the actual script..anyway i am uploading a file, as much as possible, using plain javascript but encounterred a hitch when values won’t reach to PHP file . Here are my codes..
[code=html]
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<title>Uploading File</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<script type=”text/javascript”>
<!–
function start() {
myForm=document.createElement(“form”);
myForm.action=”uploader.php”;
myForm.method=”post”;
myForm.enctype=”multipart/form-data”;
document.body.appendChild(myForm);
hidden1=document.createElement(“input”);
hidden1.type=”hidden”;
hidden1.name= “MAX_FILE_SIZE”;
hidden1.value= 2000000;
myForm.appendChild(hidden1);
//for the browse button
button1 = document.createElement(“input”);
button1.type=”file”;
button1.name=”upload”;
button1.value=””;
button1.style.position=”absolute”;
button1.style.top = 20;
button1.style.height = 30;
myForm.appendChild(button1);
//for submit button
button2 = document.createElement(“input”);
button2.type=”submit”;
button2.value=”Submit”;
button2.style.position=”absolute”;
button2.style.top = 20;
button2.style.left = 250;
button2.style.height = 30;
button2.style.width = 80;
button2.onclick=”form.submit()”;
myForm.appendChild(button2);
hidden2=document.createElement(“input”);
hidden2.type=”hidden”;
hidden2.name=”submitted”;
hidden2.value=”TRUE”;
myForm.appendChild(hidden2);
} // end of function start().
// –>
</script>
</head>
<body onLoad=”start()”>
</body>
</html>
and the PHP file or handler (uploader.php)
[code=php]
echo ‘<pre>POST: ‘; print_r($_POST); echo “</pre>n”;
echo ‘<pre>FILES: ‘; print_r($_FILES); echo “</pre>n”;
echo “<hr />n”;
die();
//this is just a trap to check wether superglobal variable $_FILES do contains
//values…beyond this point are PHP codes that actually do the uploading..
unfortunately, the result was..
[code]
POST: Array
(
[MAX_FILE_SIZE] => 2000000
[upload] => D:My FolderTempbytes conversion table.xls
[submitted] => TRUE
)
FILES: Array
(
)
i guessed my javacript code just lack something?..