Trouble sending files through IE8
I got some problem with sending files through IE8.
var form = formAppend('', OBJ.uploadFileContainer);
form.enctype = 'multipart/form-data';
form.action = 'iCal/iCalUpload.php';
form.target = 'help';
form.method = 'post';
var input = inputAppend('[type=file][name=calendarFile]', form);
var id = inputAppend('[type=hidden][name=id]', form);
$(form).submit();
I got a http 200 status which is good. But in PHP I can't really get the file with $_FILES['calendarFile']
it is issues the warning undefined index. It works well in all browser version except for IE < 9. Any idea of how to fix this?
Forgot to mention that inputAppend() is a DOM creation function I'm using. It creates an input Element and add the attributes using jquery selectors. There is definetly not wrong with it.
PHP Code
$errorMessage = 'invalid File';
if ($_FILE开发者_开发技巧S["calendarFile"]["size"] < 100000 && //Undefined Index Warning in PHP
($_FILES['calendarFile']['type'] == 'text/calendar' || $_FILES['file']['type'] == 'text/x-vcalendar')){
if ($_FILES["calendarFile"]["error"] > 0){
$errorMessage = $_FILES["calendarFile"]["error"];
}else{
$timeStamp = time();
$errorMessage = 'The file was succesfully uploaded!';
move_uploaded_file( $_FILES["calendarFile"]["tmp_name"], "upload/$timeStamp"."-".$_FILES['calendarFile']['name']);
}
}
精彩评论