Php 为什么我的表格没有';在iE8中不发送文件?
我正在用php做一个简单的文件格式,它与safari、mozilla(mac&pc)chrome(mac&pc)一起使用,而不是IE8,我的$u文件是Emply 标题:Php 为什么我的表格没有';在iE8中不发送文件?,php,html,forms,file-upload,Php,Html,Forms,File Upload,我正在用php做一个简单的文件格式,它与safari、mozilla(mac&pc)chrome(mac&pc)一起使用,而不是IE8,我的$u文件是Emply 标题: <?php session_start(); header('P3P: CP="NON DSP TAIa PSAa PSDa OUR IND UNI", policyref="/w3c/p3p.xml"'); header('P3P: CP="CAO PSA OUR"'); ?> <!DOCTYPE html
<?php
session_start();
header('P3P: CP="NON DSP TAIa PSAa PSDa OUR IND UNI", policyref="/w3c/p3p.xml"');
header('P3P: CP="CAO PSA OUR"');
?>
<!DOCTYPE html>
<html>
<head>
<title>mcp</title>
<meta name="apple-mobile-web-app-capable" content="no">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=IE8">
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<meta http-equiv="Content-type" content="text/html;charset=utf-8" />
<!-- CSS -->
<link rel="stylesheet/less" type="text/css" href="../styles/design.less"/>
<link rel="stylesheet/less" type="text/css" href="../styles/style.css"/>
<!--JS -->
<script src="../js/less.min.js"></script>
<script src="../js/jquery-1.9.1.min.js"></script>
<script src="../js/parsley.js"></script>
</head>
<body>
<div id="header-pic">
<img src="../styles/img/header_pic.png" alt="header-pic" />
</div>
<div id="mpcp">
<img src="../styles/img/mpcp.png" alt="mpcp" />
</div>
执行上传的php代码在哪里?你关闭了
标签吗?是的,我关闭了表单标签,只是忘了赶紧把它放进去。我不相信这个简单的表单在IE8中不起作用,事实上,在你使用HTML5之前,它与IE8+没有任何关系。需要整个HTML代码。我只是添加了标题,信不信由你,但它只适用于ie
<form action="thanks.php" method="post" data-validate="parsley" enctype="multipart/form-data">
<label for="input-firstname">First name</label>
<input data-required="true" type="text" class="text" id="input-name-field" name="firstname"/><br>
<label for="input-lastname">Last name</label>
<input data-required="true" type="text" class="text" id="input-surname-field" name="lastname"/><br>
<label for="input-mail">e-mail</label>
<input data-type="email" data-required="true" type="text" class="text" id="input-mail-field" name="email"/><br>
<label for="input-picture">Picture</label>
<input type="button" id="clickme" value="Browse" />
<input type="text" id="filename" />
<input type="file" name="file" id="uploadme" />
<input id="validate" type="submit" value="VALIDATE">
</form>
if (isset($_POST['firstname']) && isset($_POST['lastname']) && isset($_POST['email']) && isset($_FILES["file"]) && $_FILES["file"]["name"] != '') {
$_SESSION['firstname'] = $_POST['firstname'];
$_SESSION['lastname'] = $_POST['lastname'];
$_SESSION['email'] = $_POST['email'];
$_SESSION['photo'] = $_POST['firstname'].'-'.$_POST['lastname'];
$allowedExts = array("gif", "jpeg", "jpg", "png");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
$_SESSION['photo'] = $_POST['firstname'].'-'.$_POST['lastname'].'.'.$extension;
if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") ||
($_FILES["file"]["type"] == "image/jpg") || ($_FILES["file"]["type"] == "image/pjpeg") ||
($_FILES["file"]["type"] == "image/x-png") || ($_FILES["file"]["type"] == "image/png")) && ($_FILES["file"]["size"] < 1000000) && in_array($extension, $allowedExts)) {
if ($_FILES["file"]["error"] > 0) {
$error = $_FILES["file"]["error"];
} else {
$_FILES["file"]["name"] = $_POST['firstname'].'-'.$_POST['lastname'];
echo "Upload: " . $_FILES["file"]["name"] . "<br>";
echo "Type: " . $_FILES["file"]["type"] . "<br>";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";
if (file_exists("../upload/" . $_FILES["file"]["name"])){
unlink("../upload/" . $_FILES["file"]["name"]);
}
$res = move_uploaded_file($_FILES["file"]["tmp_name"], "../upload/" . $_FILES["file"]["name"].'.'.$extension);
if ($res == true) {
echo "Stored in: " . "../upload/" . $_FILES["file"]["name"];
} else {
$error = "Invalid file";
}
}
} else {
$error = "Invalid file";
}
} else {
header("Location: reglement.php");
}