【发布时间】:2014-01-18 02:36:13
【问题描述】:
我有这个基本的上传代码:
<form action="upload.php" method="post" >
<input type="file" name="file" value="" />
<input type="submit" name="submit" value="Go" />
</form>
<?php
if(isset($_POST['submit'])){
echo '<h3>Post test: </h3>';
var_dump($_POST);
$csv = array();
if(isset($_FILES["file"])) {
//if there was an error uploading the file
if($_FILES["file"]["error"] > 0) {
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else {
//Print file details
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 />";
}
}
else {
echo "No file selected <br />";
}
}
我不断收到“未选择文件”,这是 isset($_FILES['file'] 的 else 后备。
我的 php.ini 文件中是否需要设置某些内容以允许我将文件上传到临时位置?除了提交表单以将文件设置为$_FILES之外,我还需要做些什么吗?
【问题讨论】:
标签: php html file-upload